replace reva by fork
Signed-off-by: Christian Richter <c.richter@opencloud.eu>
This commit is contained in:
+5
@@ -85,6 +85,11 @@ func (fs *owncloudsqlfs) ListStorageSpaces(ctx context.Context, filter []*provid
|
||||
}
|
||||
spaces = append(spaces, space)
|
||||
}
|
||||
|
||||
for _, space := range spaces {
|
||||
space.HasTrashedItems = false // owncloudsql does not support checking for trashed items
|
||||
}
|
||||
|
||||
return spaces, nil
|
||||
}
|
||||
|
||||
|
||||
+23
@@ -397,3 +397,26 @@ func (tb *Trashbin) EmptyRecycle(ctx context.Context, spaceID string) error {
|
||||
}
|
||||
return os.RemoveAll(filepath.Clean(filepath.Join(trashRoot, "info")))
|
||||
}
|
||||
|
||||
func (tb *Trashbin) IsEmpty(ctx context.Context, spaceID string) bool {
|
||||
_, span := tracer.Start(ctx, "HasTrashedItems")
|
||||
defer span.End()
|
||||
trashRoot := filepath.Join(tb.lu.InternalPath(spaceID, spaceID), ".Trash", "info")
|
||||
trash, err := os.Open(filepath.Clean(trashRoot))
|
||||
if err != nil {
|
||||
// there is no trash for this space, so no trashed items
|
||||
return true
|
||||
}
|
||||
dirItems, err := trash.ReadDir(1)
|
||||
if err != nil {
|
||||
// if we cannot read the trash, we assume there are no trashed items
|
||||
tb.log.Error().Err(err).Str("spaceID", spaceID).Msg("trashbin: error reading trash directory")
|
||||
return true
|
||||
}
|
||||
if len(dirItems) > 0 {
|
||||
// if we can read the trash and there are items, we assume there are trashed items
|
||||
return false
|
||||
}
|
||||
// if we cannot read the trash, we assume there are no trashed items
|
||||
return true
|
||||
}
|
||||
|
||||
+25
@@ -448,3 +448,28 @@ func (tb *DecomposedfsTrashbin) EmptyRecycle(ctx context.Context, spaceID string
|
||||
func (tb *DecomposedfsTrashbin) getRecycleRoot(spaceID string) string {
|
||||
return filepath.Join(tb.fs.o.Root, "spaces", lookup.Pathify(spaceID, 1, 2), "trash")
|
||||
}
|
||||
|
||||
func (fs *DecomposedfsTrashbin) IsEmpty(ctx context.Context, spaceID string) bool {
|
||||
log := appctx.GetLogger(ctx)
|
||||
_, span := tracer.Start(ctx, "HasTrashedItems")
|
||||
defer span.End()
|
||||
|
||||
trashRoot := fs.getRecycleRoot(spaceID)
|
||||
trash, err := os.Open(filepath.Clean(trashRoot))
|
||||
if err != nil {
|
||||
// there is no trash for this space, so no trashed items
|
||||
return true
|
||||
}
|
||||
dirItems, err := trash.ReadDir(1)
|
||||
if err != nil {
|
||||
// if we cannot read the trash, we assume there are no trashed items
|
||||
log.Error().Err(err).Str("trashRoot", trashRoot).Str("spaceID", spaceID).Msg("trashbin: error reading trash directory")
|
||||
return true
|
||||
}
|
||||
if len(dirItems) > 0 {
|
||||
// if we can read the trash and there are items, we assume there are trashed items
|
||||
return false
|
||||
}
|
||||
// if we cannot read the trash, we assume there are no trashed items
|
||||
return true
|
||||
}
|
||||
|
||||
+8
@@ -493,6 +493,14 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
|
||||
}()
|
||||
|
||||
for r := range results {
|
||||
r.HasTrashedItems = true
|
||||
resourceID, err := storagespace.ParseID(r.GetId().GetOpaqueId())
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Str("id", r.Id.GetOpaqueId()).Msg("could not parse space id")
|
||||
r.HasTrashedItems = false
|
||||
continue
|
||||
}
|
||||
r.HasTrashedItems = !fs.trashbin.IsEmpty(ctx, resourceID.GetSpaceId())
|
||||
spaces = append(spaces, r)
|
||||
}
|
||||
|
||||
|
||||
Generated
Vendored
+1
@@ -33,4 +33,5 @@ type Trashbin interface {
|
||||
RestoreRecycleItem(ctx context.Context, spaceID, key, relativePath string, restoreRef *provider.Reference) (*node.Node, error)
|
||||
PurgeRecycleItem(ctx context.Context, spaceID, key, relativePath string) error
|
||||
EmptyRecycle(ctx context.Context, spaceID string) error
|
||||
IsEmpty(ctx context.Context, spaceID string) bool
|
||||
}
|
||||
|
||||
+1
@@ -493,6 +493,7 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
|
||||
}()
|
||||
|
||||
for r := range results {
|
||||
r.HasTrashedItems = false // FIXME: implement me
|
||||
spaces = append(spaces, r)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user