aboutsummaryrefslogtreecommitdiff
path: root/backend/studip
diff options
context:
space:
mode:
Diffstat (limited to 'backend/studip')
-rw-r--r--backend/studip/fs.go37
1 files changed, 24 insertions, 13 deletions
diff --git a/backend/studip/fs.go b/backend/studip/fs.go
index df18171..32ed19a 100644
--- a/backend/studip/fs.go
+++ b/backend/studip/fs.go
@@ -1339,7 +1339,7 @@ func (f *Fs) updateRelativeRootFromTree() {
fs.Debugf(f, "resolved relative root path=%q id=%q", rootNode.Path, rootNode.ID)
}
-func (f *Fs) Rmdir(ctx context.Context, dir string) error {
+func (f *Fs) rmdir(ctx context.Context, dir string, purge bool) error {
if ctx.Err() != nil {
return ctx.Err()
}
@@ -1393,18 +1393,21 @@ func (f *Fs) Rmdir(ctx context.Context, dir string) error {
if err != nil {
return err
}
- if len(node.Children) > 0 {
- if refreshErr := f.refreshFileTree(ctx); refreshErr != nil {
- fs.Debugf(f, "Rmdir: refresh before empty check failed dir=%q err=%v", dir, refreshErr)
- } else {
- node, err = lookupNode()
- if err != nil {
- return err
- }
- }
+ if !purge {
if len(node.Children) > 0 {
- return fs.ErrorDirectoryNotEmpty
+ if refreshErr := f.refreshFileTree(ctx); refreshErr != nil {
+ fs.Debugf(f, "Rmdir: refresh before empty check failed dir=%q err=%v", dir, refreshErr)
+ } else {
+ node, err = lookupNode()
+ if err != nil {
+ return err
+ }
+ }
+
+ if len(node.Children) > 0 {
+ return fs.ErrorDirectoryNotEmpty
+ }
}
}
@@ -1431,6 +1434,10 @@ func (f *Fs) Rmdir(ctx context.Context, dir string) error {
return nil
}
+func (f *Fs) Rmdir(ctx context.Context, dir string) error {
+ return f.rmdir(ctx, dir, false)
+}
+
func (f *Fs) TestConnection(
ctx context.Context,
) error {
@@ -1471,12 +1478,16 @@ func (f *Fs) Features() *fs.Features {
return (&fs.Features{
CanHaveEmptyDirectories: true,
CaseInsensitive: true,
- Copy: nil,
- Purge: nil,
+ // TODO: Implement this
+ Copy: nil,
}).
Fill(context.Background(), f)
}
+func (f *Fs) Purge(ctx context.Context, dir string) error {
+ return f.rmdir(ctx, dir, true)
+}
+
func (f *Fs) Move(
ctx context.Context,
src fs.Object,