Skip to content

Commit

Permalink
feat(operation-purge-flow): enable delete directory now
Browse files Browse the repository at this point in the history
Remove a directory or container and all of its contents
  • Loading branch information
ElonH committed Jun 1, 2020
1 parent 7e7dd78 commit e7e49e5
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/@dataflow/rclone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ export * from './operations-movefile-flow';
export * from './operations-deletefile-flow';
export * from './sync-copy-flow';
export * from './sync-move-flow';
export * from './operations-purge-flow';
39 changes: 39 additions & 0 deletions src/app/@dataflow/rclone/operations-purge-flow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { IRcloneServer } from '../extra';
import { CombErr } from '../core';
import { AsyncPostFlow, AsyncPostFlowParamsNode } from './async-post-flow';

export interface OperationsPurgeFlowParamsNode extends AsyncPostFlowParamsNode {
/** a remote name string eg "drive:" */
srcFs: string;
/** a path within that remote eg "dir" */
srcRemote: string;
}

export interface OperationsPurgeFlowInNode
extends OperationsPurgeFlowParamsNode,
IRcloneServer {}

interface OperationsPurgeFlowInnerParamsNode extends AsyncPostFlowParamsNode {
/** a remote name string eg "drive:" */
fs: string;
/** a path within that remote eg "dir" */
remote: string;
}

export abstract class OperationsPurgeFlow extends AsyncPostFlow<
OperationsPurgeFlowInNode,
OperationsPurgeFlowInnerParamsNode
> {
// public prerequest$: Observable<CombErr<OperationsPurgeFlowInNode>>;
protected cmd: string = 'operations/purge';
protected params = (
pre: CombErr<OperationsPurgeFlowInNode>
): OperationsPurgeFlowInnerParamsNode => {
if (pre[1].length !== 0) return {} as any;
return {
fs: pre[0].srcFs,
remote: pre[0].srcRemote,
};
};
protected cacheSupport: boolean = false;
}
34 changes: 34 additions & 0 deletions src/app/pages/manager/tasks/tasks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
SyncCopyFlowInNode,
SyncMoveFlow,
SyncMoveFlowInNode,
OperationsPurgeFlow,
OperationsPurgeFlowInNode,
} from 'src/app/@dataflow/rclone';
import {
ClipboardService,
Expand Down Expand Up @@ -252,6 +254,37 @@ export class TaskService {
});
}

private purge$: OperationsPurgeFlow;
private deployPurge() {
const outer = this;
const taskReal$ = outer.post$.pipe(filter((x) => x.oper === 'del' && x.srcItem.IsDir));
this.purge$ = new (class extends OperationsPurgeFlow {
public prerequest$ = taskReal$.pipe(
withLatestFrom(outer.connectService.listCmd$.verify(this.cmd)),
map(
([item, cmdNode]): CombErr<OperationsPurgeFlowInNode> => {
if (cmdNode[1].length !== 0) return [{}, cmdNode[1]] as any;
return [
{
...cmdNode[0],
srcFs: `${item.srcRemote}:`,
srcRemote: item.srcItem.Path,
},
[],
];
}
)
);
})();
this.purge$.deploy();
this.purge$
.getOutput()
.pipe(zip(taskReal$))
.subscribe((x) => {
this.postAfter(...x);
});
}

private detailTrigger = new Subject<number>();
public detail$: TasksPoolFlow;
private deployDetail() {
Expand Down Expand Up @@ -292,6 +325,7 @@ export class TaskService {
this.deployDeleteFile();
this.deploySyncCopy();
this.deploySyncMove();
this.deployPurge();
this.deployDetail();
}
}

0 comments on commit e7e49e5

Please sign in to comment.