Bump reva
This commit is contained in:
+2
-9
@@ -49,7 +49,6 @@ const RevisionsDir = ".oc-nodes"
|
||||
|
||||
var _spaceTypePersonal = "personal"
|
||||
var _spaceTypeProject = "project"
|
||||
var _currentSuffix = ".current"
|
||||
|
||||
func init() {
|
||||
tracer = otel.Tracer("github.com/cs3org/reva/pkg/storage/pkg/decomposedfs/lookup")
|
||||
@@ -279,18 +278,12 @@ func (lu *Lookup) InternalRoot() string {
|
||||
|
||||
// InternalPath returns the internal path for a given ID
|
||||
func (lu *Lookup) InternalPath(spaceID, nodeID string) string {
|
||||
if strings.Contains(nodeID, node.RevisionIDDelimiter) {
|
||||
if strings.Contains(nodeID, node.RevisionIDDelimiter) || strings.HasSuffix(nodeID, node.CurrentIDDelimiter) {
|
||||
spaceRoot, _ := lu.IDCache.Get(context.Background(), spaceID, spaceID)
|
||||
if len(spaceRoot) == 0 {
|
||||
return ""
|
||||
}
|
||||
return filepath.Join(spaceRoot, RevisionsDir, Pathify(nodeID, 4, 2))
|
||||
} else if strings.HasSuffix(nodeID, node.CurrentIDDelimiter) {
|
||||
spaceRoot, _ := lu.IDCache.Get(context.Background(), spaceID, spaceID)
|
||||
if len(spaceRoot) == 0 {
|
||||
return ""
|
||||
}
|
||||
filepath.Join(spaceRoot, RevisionsDir, Pathify(nodeID, 4, 2)+_currentSuffix)
|
||||
}
|
||||
|
||||
path, _ := lu.IDCache.Get(context.Background(), spaceID, nodeID)
|
||||
@@ -315,7 +308,7 @@ func (lu *Lookup) CurrentPath(spaceID, nodeID string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return filepath.Join(spaceRoot, RevisionsDir, Pathify(nodeID, 4, 2)+_currentSuffix)
|
||||
return filepath.Join(spaceRoot, RevisionsDir, Pathify(nodeID, 4, 2)+node.CurrentIDDelimiter)
|
||||
}
|
||||
|
||||
// refFromCS3 creates a CS3 reference from a set of bytes. This method should remain private
|
||||
|
||||
+9
-11
@@ -381,17 +381,6 @@ func (t *Tree) assimilate(item scanItem) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// compare metadata mtime with actual mtime. if it matches we can skip the assimilation because the file was handled by us
|
||||
fi, err := os.Stat(item.Path)
|
||||
if err == nil {
|
||||
// FIXME the mtime does not change on a move, so we have to compare ctime
|
||||
stat := fi.Sys().(*syscall.Stat_t)
|
||||
ctime := time.Unix(int64(stat.Ctim.Sec), int64(stat.Ctim.Nsec))
|
||||
if mtime.Equal(ctime) && !item.ForceRescan {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if id != "" {
|
||||
// the file has an id set, we already know it from the past
|
||||
n := node.NewBaseNode(spaceID, id, t.lookup)
|
||||
@@ -399,6 +388,15 @@ func (t *Tree) assimilate(item scanItem) error {
|
||||
previousPath, ok := t.lookup.(*lookup.Lookup).GetCachedID(context.Background(), spaceID, string(id))
|
||||
previousParentID, _ := t.lookup.MetadataBackend().Get(context.Background(), n, prefixes.ParentidAttr)
|
||||
|
||||
// compare metadata mtime with actual mtime. if it matches AND the path hasn't changed (move operation)
|
||||
// we can skip the assimilation because the file was handled by us
|
||||
fi, err := os.Stat(item.Path)
|
||||
if err == nil && previousPath == item.Path {
|
||||
if mtime.Equal(fi.ModTime()) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// was it moved or copied/restored with a clashing id?
|
||||
if ok && len(previousParentID) > 0 && previousPath != item.Path {
|
||||
_, err := os.Stat(previousPath)
|
||||
|
||||
+9
-9
@@ -120,9 +120,17 @@ func (fs *Decomposedfs) RestoreRevision(ctx context.Context, ref *provider.Refer
|
||||
return err
|
||||
}
|
||||
|
||||
// revision 5, current 10 (restore a smaller blob) -> 5-10 = -5
|
||||
// revision 10, current 5 (restore a bigger blob) -> 10-5 = +5
|
||||
revisionNode := node.NewBaseNode(spaceID, revisionKey, fs.lu)
|
||||
revisionSize, err := fs.lu.MetadataBackend().GetInt64(ctx, revisionNode, prefixes.BlobsizeAttr)
|
||||
if err != nil {
|
||||
return errtypes.InternalError("failed to read blob size xattr from old revision")
|
||||
}
|
||||
sizeDiff := revisionSize - n.Blobsize
|
||||
|
||||
// restore revision
|
||||
restoredRevisionPath := fs.lu.InternalPath(spaceID, revisionKey)
|
||||
revisionNode := node.NewBaseNode(spaceID, revisionKey, fs.lu)
|
||||
if err := fs.tp.RestoreRevision(ctx, revisionNode, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -141,14 +149,6 @@ func (fs *Decomposedfs) RestoreRevision(ctx context.Context, ref *provider.Refer
|
||||
log.Warn().Err(err).Interface("ref", ref).Str("originalnode", kp[0]).Str("revisionKey", revisionKey).Msg("could not purge old revision from cache, continuing")
|
||||
}
|
||||
|
||||
// revision 5, current 10 (restore a smaller blob) -> 5-10 = -5
|
||||
// revision 10, current 5 (restore a bigger blob) -> 10-5 = +5
|
||||
revisionSize, err := fs.lu.MetadataBackend().GetInt64(ctx, revisionNode, prefixes.BlobsizeAttr)
|
||||
if err != nil {
|
||||
return errtypes.InternalError("failed to read blob size xattr from old revision")
|
||||
}
|
||||
sizeDiff := revisionSize - n.Blobsize
|
||||
|
||||
return fs.tp.Propagate(ctx, n, sizeDiff)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user