From b4a1fbf4dfae391c4dd024a451052fbc06a02677 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Fri, 6 May 2022 12:36:42 +0200 Subject: [PATCH 1/2] fix owncloudsql upload without mtime --- changelog/unreleased/fix-owncloudsql-storage-no-mtime.md | 6 ++++++ pkg/storage/fs/owncloudsql/upload.go | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 changelog/unreleased/fix-owncloudsql-storage-no-mtime.md diff --git a/changelog/unreleased/fix-owncloudsql-storage-no-mtime.md b/changelog/unreleased/fix-owncloudsql-storage-no-mtime.md new file mode 100644 index 0000000000..a034572c45 --- /dev/null +++ b/changelog/unreleased/fix-owncloudsql-storage-no-mtime.md @@ -0,0 +1,6 @@ +Bugfix: Fix uploads to owncloudsql storage when no mtime is provided + +We've fixed uploads to owncloudsql storage when no mtime is provided. +We now just use the current timestamp. Previously the upload did fail. + +https://github.com/cs3org/reva/pull/2831 diff --git a/pkg/storage/fs/owncloudsql/upload.go b/pkg/storage/fs/owncloudsql/upload.go index bece39e4d5..f7df96e67f 100644 --- a/pkg/storage/fs/owncloudsql/upload.go +++ b/pkg/storage/fs/owncloudsql/upload.go @@ -27,6 +27,7 @@ import ( "os" "path/filepath" "strconv" + "time" userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" @@ -107,6 +108,8 @@ func (fs *owncloudsqlfs) InitiateUpload(ctx context.Context, ref *provider.Refer if metadata != nil { if metadata["mtime"] != "" { info.MetaData["mtime"] = metadata["mtime"] + } else { + info.MetaData["mtime"] = strconv.FormatInt(time.Now().Unix(), 10) } if _, ok := metadata["sizedeferred"]; ok { info.SizeIsDeferred = true From 34970a1569b86f7c0bda086b51620ebe8067bbb0 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Fri, 6 May 2022 12:47:31 +0200 Subject: [PATCH 2/2] set default mtime --- pkg/storage/fs/owncloudsql/upload.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/storage/fs/owncloudsql/upload.go b/pkg/storage/fs/owncloudsql/upload.go index f7df96e67f..ace1688246 100644 --- a/pkg/storage/fs/owncloudsql/upload.go +++ b/pkg/storage/fs/owncloudsql/upload.go @@ -101,6 +101,7 @@ func (fs *owncloudsqlfs) InitiateUpload(ctx context.Context, ref *provider.Refer MetaData: tusd.MetaData{ "filename": filepath.Base(p), "dir": filepath.Dir(p), + "mtime": strconv.FormatInt(time.Now().Unix(), 10), }, Size: uploadLength, } @@ -108,8 +109,6 @@ func (fs *owncloudsqlfs) InitiateUpload(ctx context.Context, ref *provider.Refer if metadata != nil { if metadata["mtime"] != "" { info.MetaData["mtime"] = metadata["mtime"] - } else { - info.MetaData["mtime"] = strconv.FormatInt(time.Now().Unix(), 10) } if _, ok := metadata["sizedeferred"]; ok { info.SizeIsDeferred = true