mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
files - final fixes for PR
This commit is contained in:
parent
4d10c16310
commit
7ca0c85dfe
|
@ -988,7 +988,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
}
|
||||
|
||||
if (useTrash && atomic) {
|
||||
throw new Error(localize('deleteFailedTrashAndAtomicUnsupported', "Unable to delete file '{0}' with option to use trash and atomic both enabled.", this.resourceForError(resource)));
|
||||
throw new Error(localize('deleteFailedTrashAndAtomicUnsupported', "Unable to atomically delete file '{0}' because using trash is enabled.", this.resourceForError(resource)));
|
||||
}
|
||||
|
||||
// Validate delete
|
||||
|
@ -1167,7 +1167,11 @@ export class FileService extends Disposable implements IFileService {
|
|||
} catch (error) {
|
||||
|
||||
// Cleanup in case of rename error
|
||||
await provider.delete(resource, { recursive: false, useTrash: false, atomic: false });
|
||||
try {
|
||||
await provider.delete(tempResource, { recursive: false, useTrash: false, atomic: false });
|
||||
} catch (error) {
|
||||
// ignore - we want the outer error to bubble up
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
|
|
@ -258,12 +258,16 @@ export class DiskFileSystemProvider extends AbstractDiskFileSystemProvider imple
|
|||
try {
|
||||
|
||||
// Rename over existing to ensure atomic replace
|
||||
await this.rename(tempResource, resource, { overwrite: opts.overwrite });
|
||||
await this.rename(tempResource, resource, { overwrite: true });
|
||||
|
||||
} catch (error) {
|
||||
|
||||
// Cleanup in case of rename error
|
||||
await this.delete(tempResource, { recursive: false, useTrash: false, atomic: false });
|
||||
try {
|
||||
await this.delete(tempResource, { recursive: false, useTrash: false, atomic: false });
|
||||
} catch (error) {
|
||||
// ignore - we want the outer error to bubble up
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
@ -583,12 +587,12 @@ export class DiskFileSystemProvider extends AbstractDiskFileSystemProvider imple
|
|||
try {
|
||||
const filePath = this.toFilePath(resource);
|
||||
if (opts.recursive) {
|
||||
let atomicDeleteTarget: string | undefined = undefined;
|
||||
let rmMoveToPath: string | undefined = undefined;
|
||||
if (opts?.atomic !== false && opts.atomic.postfix) {
|
||||
atomicDeleteTarget = join(dirname(filePath), `${basename(filePath)}${opts.atomic.postfix}`);
|
||||
rmMoveToPath = join(dirname(filePath), `${basename(filePath)}${opts.atomic.postfix}`);
|
||||
}
|
||||
|
||||
await Promises.rm(filePath, RimRafMode.MOVE, atomicDeleteTarget);
|
||||
await Promises.rm(filePath, RimRafMode.MOVE, rmMoveToPath);
|
||||
} else {
|
||||
try {
|
||||
await Promises.unlink(filePath);
|
||||
|
|
Loading…
Reference in a new issue