Skip to content

Commit

Permalink
fix restoring versions (#2270)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas authored Nov 16, 2021
1 parent 3b01f9e commit 1aff0be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 37 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-restoring-version.md
Original file line number Diff line number Diff line change
@@ -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
19 changes: 0 additions & 19 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
19 changes: 1 addition & 18 deletions pkg/storage/utils/decomposedfs/revisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 1aff0be

Please sign in to comment.