Skip to content

Commit

Permalink
fix restoring versions
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas committed Nov 12, 2021
1 parent 17606d3 commit fbe0d53
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-restoring-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix restoring versions

TODO: change text

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 fbe0d53

Please sign in to comment.