Merge branch '8784-dir-listings'
[arvados.git] / sdk / go / arvados / keep_service.go
index 4af1b7910f6f3b111583ad91fa5416ef520b4ac5..7f9d869e0cead2fdc766fb9deac95f2a9b99e420 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 package arvados
 
 import (
@@ -30,6 +34,7 @@ type KeepServiceList struct {
 // us about a stored block.
 type KeepServiceIndexEntry struct {
        SizedDigest
+       // Time of last write, in nanoseconds since Unix epoch
        Mtime int64
 }
 
@@ -108,6 +113,14 @@ func (s *KeepService) Index(c *Client, prefix string) ([]KeepServiceIndexEntry,
                if err != nil {
                        return nil, fmt.Errorf("Malformed index line %q: mtime: %v", line, err)
                }
+               if mtime < 1e12 {
+                       // An old version of keepstore is giving us
+                       // timestamps in seconds instead of
+                       // nanoseconds. (This threshold correctly
+                       // handles all times between 1970-01-02 and
+                       // 33658-09-27.)
+                       mtime = mtime * 1e9
+               }
                entries = append(entries, KeepServiceIndexEntry{
                        SizedDigest: SizedDigest(fields[0]),
                        Mtime:       mtime,