Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix restoring versions #2270

Merged
merged 1 commit into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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