From 5aec1816dddca6cfd61a08a2dc69b0f743d26846 Mon Sep 17 00:00:00 2001 From: David Christofas Date: Fri, 12 Nov 2021 12:10:06 +0100 Subject: [PATCH] fix restoring versions --- changelog/unreleased/fix-restoring-version.md | 7 +++++++ .../utils/decomposedfs/decomposedfs.go | 19 ------------------- pkg/storage/utils/decomposedfs/revisions.go | 19 +------------------ 3 files changed, 8 insertions(+), 37 deletions(-) create mode 100644 changelog/unreleased/fix-restoring-version.md diff --git a/changelog/unreleased/fix-restoring-version.md b/changelog/unreleased/fix-restoring-version.md new file mode 100644 index 0000000000..92e4deac89 --- /dev/null +++ b/changelog/unreleased/fix-restoring-version.md @@ -0,0 +1,7 @@ +Bugfix: Fix restoring versions + +Restoring a version would not remove that version from the version list. +Now the behavior is compatible to ownCloud 10. + +https://github.com/owncloud/ocis/issues/1214 +https://github.com/cs3org/reva/pull/2270 diff --git a/pkg/storage/utils/decomposedfs/decomposedfs.go b/pkg/storage/utils/decomposedfs/decomposedfs.go index 447f9f8593..4ebb5c3cb2 100644 --- a/pkg/storage/utils/decomposedfs/decomposedfs.go +++ b/pkg/storage/utils/decomposedfs/decomposedfs.go @@ -517,22 +517,3 @@ func (fs *Decomposedfs) Download(ctx context.Context, ref *provider.Reference) ( } return reader, nil } - -func (fs *Decomposedfs) copyMD(s string, t string) (err error) { - var attrs []string - if attrs, err = xattr.List(s); err != nil { - return err - } - for i := range attrs { - if strings.HasPrefix(attrs[i], xattrs.OcisPrefix) { - var d []byte - if d, err = xattr.Get(s, attrs[i]); err != nil { - return err - } - if err = xattr.Set(t, attrs[i], d); err != nil { - return err - } - } - } - return nil -} diff --git a/pkg/storage/utils/decomposedfs/revisions.go b/pkg/storage/utils/decomposedfs/revisions.go index 9c3541b440..09a0d59c5f 100644 --- a/pkg/storage/utils/decomposedfs/revisions.go +++ b/pkg/storage/utils/decomposedfs/revisions.go @@ -180,25 +180,8 @@ func (fs *Decomposedfs) RestoreRevision(ctx context.Context, ref *provider.Refer // copy old revision to current location revisionPath := fs.lu.InternalPath(revisionKey) - var revision, destination *os.File - revision, err = os.Open(revisionPath) - if err != nil { - return - } - defer revision.Close() - destination, err = os.OpenFile(nodePath, os.O_CREATE|os.O_WRONLY, defaultFilePerm) - if err != nil { - return - } - defer destination.Close() - _, err = io.Copy(destination, revision) - if err != nil { - return - } - - err = fs.copyMD(revisionPath, nodePath) - if err != nil { + if err = os.Rename(revisionPath, nodePath); err != nil { return }