mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-05 12:40:26 -06:00
fix: recursive delete error
This commit is contained in:
@@ -31,6 +31,9 @@ class LLRmDir extends LLFilesystemOperation {
|
||||
actor,
|
||||
descendants_only,
|
||||
recursive,
|
||||
|
||||
// internal use only - not for clients
|
||||
ignore_not_empty,
|
||||
|
||||
max_tasks = 8,
|
||||
} = this.values;
|
||||
@@ -61,7 +64,7 @@ class LLRmDir extends LLFilesystemOperation {
|
||||
await target.get('uid')
|
||||
);
|
||||
|
||||
if ( children.length > 0 && ! recursive ) {
|
||||
if ( children.length > 0 && ! recursive && ! ignore_not_empty ) {
|
||||
throw APIError.create('not_empty');
|
||||
}
|
||||
|
||||
@@ -100,7 +103,13 @@ class LLRmDir extends LLFilesystemOperation {
|
||||
|
||||
await tasks.awaitAll();
|
||||
if ( ! descendants_only ) {
|
||||
await target.provider.rmdir({ context, node: target });
|
||||
await target.provider.rmdir({
|
||||
context,
|
||||
node: target,
|
||||
options: {
|
||||
ignore_not_empty: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ class PuterFSProvider extends putility.AdvancedBase {
|
||||
await this.rmnode_({ context, node });
|
||||
}
|
||||
|
||||
async rmdir ({ context, node }) {
|
||||
async rmdir ({ context, node, options = {} }) {
|
||||
if ( await node.get('type') !== TYPE_DIRECTORY ) {
|
||||
console.log(`\x1B[31;1m===D1====${await node.get('path')}=========\x1B[0m`)
|
||||
throw new APIError(409, 'Cannot rmdir a file.');
|
||||
@@ -386,15 +386,15 @@ class PuterFSProvider extends putility.AdvancedBase {
|
||||
await node.get('uid')
|
||||
);
|
||||
|
||||
if ( children.length > 0 ) {
|
||||
if ( children.length > 0 && ! options.ignore_not_empty ) {
|
||||
console.log(`\x1B[31;1m===D3====${await node.get('path')}=========\x1B[0m`)
|
||||
throw APIError.create('not_empty');
|
||||
}
|
||||
|
||||
await this.rmnode_({ context, node });
|
||||
await this.rmnode_({ context, node, options });
|
||||
}
|
||||
|
||||
async rmnode_ ({ context, node }) {
|
||||
async rmnode_ ({ context, node, options }) {
|
||||
// Services
|
||||
const services = context.get('services');
|
||||
const svc_size = services.get('sizeService');
|
||||
|
||||
Reference in New Issue
Block a user