-
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-1918] feat: allow to edit files append content (#475)
- Loading branch information
1 parent
b43a5b6
commit f9f753a
Showing
62 changed files
with
783 additions
and
222 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { OfflineDriveDependencyContainer } from '../dependency-injection/offline/OfflineDriveDependencyContainer'; | ||
import { VirtualDriveDependencyContainer } from '../dependency-injection/virtual-drive/VirtualDriveDependencyContainer'; | ||
import { FileStatuses } from '../../../context/virtual-drive/files/domain/FileStatus'; | ||
import { Either, right } from '../../../context/shared/domain/Either'; | ||
import { FuseError } from './FuseErrors'; | ||
|
||
type Result = 'no-op' | 'success'; | ||
|
||
export class UploadOnRename { | ||
private static readonly NO_OP: Result = 'no-op'; | ||
private static readonly SUCCESS: Result = 'success'; | ||
constructor( | ||
private readonly offline: OfflineDriveDependencyContainer, | ||
private readonly virtual: VirtualDriveDependencyContainer | ||
) {} | ||
|
||
async run(src: string, dest: string): Promise<Either<FuseError, Result>> { | ||
const offlineFile = await this.offline.offlineFileSearcher.run({ | ||
path: src, | ||
}); | ||
|
||
const virtualFile = await this.virtual.filesSearcher.run({ | ||
path: dest, | ||
status: FileStatuses.EXISTS, | ||
}); | ||
|
||
if (!offlineFile || !virtualFile) { | ||
return right(UploadOnRename.NO_OP); | ||
} | ||
|
||
await this.offline.offlineContentsUploader.run( | ||
offlineFile.id, | ||
offlineFile.path, | ||
virtualFile.contentsId | ||
); | ||
|
||
return right(UploadOnRename.SUCCESS); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { exec } from 'child_process'; | ||
import Fuse from 'fuse-native'; | ||
|
||
export function unmountFusedDirectory(mountPoint: string): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
exec(`umount ${mountPoint}`, (error, stdout: string, stderr: string) => { | ||
if (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (stderr) { | ||
// If there's anything in stderr, it usually indicates an error | ||
reject(new Error(stderr)); | ||
return; | ||
} | ||
|
||
resolve(stdout); | ||
}); | ||
}); | ||
} | ||
|
||
export function mountPromise(fuse: Fuse): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
fuse.mount((err: unknown) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
|
||
resolve(); | ||
}); | ||
}); | ||
} | ||
|
||
export function unmountPromise(fuse: Fuse): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
fuse.unmount((err: unknown) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
|
||
resolve(); | ||
}); | ||
}); | ||
} |
2 changes: 1 addition & 1 deletion
2
src/apps/sync-engine/dependency-injection/files/FilesContainer.ts
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
Oops, something went wrong.