-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PB-1919] feat: override files on .tmp renamed (#476)
- Loading branch information
1 parent
f9f753a
commit 2f3a28c
Showing
42 changed files
with
494 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export class AsyncFunctionQueue { | ||
private readonly queue = new Map<string, Promise<void>>(); | ||
|
||
constructor( | ||
private readonly asyncFunction: (...params: any[]) => Promise<void> | ||
) {} | ||
|
||
async enqueue(...params: any[]): Promise<void> { | ||
const key = params[0]; | ||
|
||
if (this.queue.has(key)) { | ||
const promise = this.queue.get(key); | ||
await promise; | ||
} | ||
|
||
const added = this.asyncFunction(...params); | ||
this.queue.set(key, added); | ||
|
||
try { | ||
await added; | ||
} finally { | ||
this.queue.delete(key); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { NotifyFuseCallback } from './FuseCallback'; | ||
|
||
export class AccessCallback extends NotifyFuseCallback { | ||
constructor() { | ||
super('Access', { input: true, output: true }); | ||
} | ||
|
||
async execute() { | ||
return this.right(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { NotifyFuseCallback } from './FuseCallback'; | ||
|
||
export class ChownCallback extends NotifyFuseCallback { | ||
constructor() { | ||
super('Chown', { input: true, output: true }); | ||
} | ||
|
||
async execute(_path: string, _uid: number, _gid: number) { | ||
return this.right(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
import { OfflineDriveDependencyContainer } from '../dependency-injection/offline/OfflineDriveDependencyContainer'; | ||
import { VirtualDriveDependencyContainer } from '../dependency-injection/virtual-drive/VirtualDriveDependencyContainer'; | ||
import { FuseCallback } from './FuseCallback'; | ||
|
||
export class ReaddirCallback extends FuseCallback<Array<string>> { | ||
constructor(private readonly container: VirtualDriveDependencyContainer) { | ||
constructor( | ||
private readonly virtual: VirtualDriveDependencyContainer, | ||
private readonly offline: OfflineDriveDependencyContainer | ||
) { | ||
super('Read Directory'); | ||
} | ||
|
||
async execute(path: string) { | ||
const filesNamesPromise = | ||
this.container.filesByFolderPathNameLister.run(path); | ||
this.virtual.filesByFolderPathNameLister.run(path); | ||
|
||
const folderNamesPromise = | ||
this.container.foldersByParentPathLister.run(path); | ||
const folderNamesPromise = this.virtual.foldersByParentPathLister.run(path); | ||
|
||
const offlineFiles = await this.offline.offlineFilesByParentPathLister.run( | ||
path | ||
); | ||
|
||
const auxiliaryFileName = offlineFiles | ||
.filter((file) => file.isAuxiliary()) | ||
.map((file) => file.name); | ||
|
||
const [filesNames, foldersNames] = await Promise.all([ | ||
filesNamesPromise, | ||
folderNamesPromise, | ||
]); | ||
|
||
return this.right(['.', '..', ...filesNames, ...foldersNames]); | ||
return this.right([ | ||
'.', | ||
'..', | ||
...filesNames, | ||
...foldersNames, | ||
...auxiliaryFileName, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.