mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Implement a no sync rule (#7216)
* implement a no sync rule * fix linting disable * fix unused imports * exclude more testing * clean up fs usage * clean up more fs usage * remove duplicate of code * fix compile errors
This commit is contained in:
@@ -10,8 +10,7 @@ import * as crypto from 'crypto';
|
||||
import * as os from 'os';
|
||||
import * as findRemoveSync from 'find-remove';
|
||||
import * as constants from './constants';
|
||||
import * as fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { promises as fs } from 'fs';
|
||||
|
||||
const configTracingLevel = 'tracingLevel';
|
||||
const configLogRetentionMinutes = 'logRetentionMinutes';
|
||||
@@ -31,17 +30,6 @@ export function getAppDataPath() {
|
||||
}
|
||||
}
|
||||
|
||||
export namespace pfs {
|
||||
|
||||
export function exists(path: string): Promise<boolean> {
|
||||
return promisify(fs.exists)(path);
|
||||
}
|
||||
|
||||
export function mkdir(path: string, mode?: number): Promise<void> {
|
||||
return promisify(fs.mkdir)(path, mode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a file name that is not already used in the target directory
|
||||
* @param filePath source notebook file name
|
||||
@@ -61,14 +49,6 @@ export function findNextUntitledEditorName(filePath: string): string {
|
||||
return title;
|
||||
}
|
||||
|
||||
export function fileExists(file: string): boolean {
|
||||
return fs.existsSync(file);
|
||||
}
|
||||
|
||||
export function copyFile(source: string, target: string): void {
|
||||
fs.copyFileSync(source, target);
|
||||
}
|
||||
|
||||
export function removeOldLogFiles(logPath: string, prefix: string): JSON {
|
||||
return findRemoveSync(logPath, { age: { seconds: getConfigLogRetentionSeconds() }, limit: getConfigLogFilesRemovalLimit() });
|
||||
}
|
||||
@@ -303,3 +283,12 @@ export function logDebug(msg: any): void {
|
||||
console.log(outputMsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function exists(path: string): Promise<boolean> {
|
||||
try {
|
||||
await fs.access(path);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user