Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

mailru: allow timestamps to be before the epoch 1970-01-01

Nick Craig-Woodb285efb476e5
diff --git a/backend/mailru/api/helpers.go b/backend/mailru/api/helpers.go
index d7164185f..6ac2b5d9c 100644
--- a/backend/mailru/api/helpers.go
+++ b/backend/mailru/api/helpers.go
@@ -69,6 +69,11 @@ func (w *BinWriter) WritePu64(val int64) {
w.b.Write(w.a[:binary.PutUvarint(w.a, uint64(val))])
}
+// WriteP64 writes an signed long as unsigned varint
+func (w *BinWriter) WriteP64(val int64) {
+ w.b.Write(w.a[:binary.PutUvarint(w.a, uint64(val))])
+}
+
// WriteString writes a zero-terminated string
func (w *BinWriter) WriteString(str string) {
buf := []byte(str)
diff --git a/backend/mailru/mailru.go b/backend/mailru/mailru.go
index 2df923c3c..28fafe702 100644
--- a/backend/mailru/mailru.go
+++ b/backend/mailru/mailru.go
@@ -645,12 +645,7 @@ func (f *Fs) itemToDirEntry(ctx context.Context, item *api.ListItem) (entry fs.D
return nil, -1, err
}
- mTime := int64(item.Mtime)
- if mTime < 0 {
- fs.Debugf(f, "Fixing invalid timestamp %d on mailru file %q", mTime, remote)
- mTime = 0
- }
- modTime := time.Unix(mTime, 0)
+ modTime := time.Unix(int64(item.Mtime), 0)
isDir, err := f.isDir(item.Kind, remote)
if err != nil {
@@ -2062,7 +2057,7 @@ func (o *Object) addFileMetaData(ctx context.Context, overwrite bool) error {
req.WritePu16(0) // revision
req.WriteString(o.fs.opt.Enc.FromStandardPath(o.absPath()))
req.WritePu64(o.size)
- req.WritePu64(o.modTime.Unix())
+ req.WriteP64(o.modTime.Unix())
req.WritePu32(0)
req.Write(o.mrHash)