Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should raises an error when pass invalid arguments', () => {
// $ExpectError: first argument is required
deleteAsync();
// $ExpectError: first argument must be a string
deleteAsync(69);
// $ExpectError: second argument must be an object
deleteAsync('', 69);
// $ExpectError: 'abc' is missing in options
deleteAsync('', { abc: 'test' });
deleteAsync('', {
// $ExpectError
idempotent: 'need boolean',
});
});
});
it('should raises an error when pass invalid arguments', () => {
// $ExpectError: first argument is required
deleteAsync();
// $ExpectError: first argument must be a string
deleteAsync(69);
// $ExpectError: second argument must be an object
deleteAsync('', 69);
// $ExpectError: 'abc' is missing in options
deleteAsync('', { abc: 'test' });
deleteAsync('', {
// $ExpectError
idempotent: 'need boolean',
});
});
});
it('should raises an error when pass invalid arguments', () => {
// $ExpectError: first argument is required
deleteAsync();
// $ExpectError: first argument must be a string
deleteAsync(69);
// $ExpectError: second argument must be an object
deleteAsync('', 69);
// $ExpectError: 'abc' is missing in options
deleteAsync('', { abc: 'test' });
deleteAsync('', {
// $ExpectError
idempotent: 'need boolean',
});
});
});
try {
// RC 0.60.0
await this.sdk.logout();
} catch (error) {
console.log('logout -> api logout -> catch -> error', error);
}
this.sdk = null;
try {
const servers = await RNUserDefaults.objectForKey(SERVERS);
await RNUserDefaults.setObjectForKey(SERVERS, servers && servers.filter(srv => srv[SERVER_URL] !== server));
// clear certificate for server - SSL Pinning
const certificate = await RNUserDefaults.objectForKey(extractHostname(server));
if (certificate && certificate.path) {
await RNUserDefaults.clear(extractHostname(server));
await FileSystem.deleteAsync(certificate.path);
}
} catch (error) {
console.log('logout_rn_user_defaults', error);
}
const userId = await RNUserDefaults.get(`${ TOKEN_KEY }-${ server }`);
try {
const serversDB = database.servers;
await serversDB.action(async() => {
const usersCollection = serversDB.collections.get('users');
const userRecord = await usersCollection.find(userId);
const serverCollection = serversDB.collections.get('servers');
const serverRecord = await serverCollection.find(server);
await serversDB.batch(
userRecord.prepareDestroyPermanently(),
this.isDrawing = true;
const gl = await glPromise;
gl.uniform1f(contrastLocation, this.state.contrast);
gl.drawArrays(gl.TRIANGLES, 0, 6);
gl.endFrameEXP();
// we need to use flip option because framebuffer contents are flipped vertically
const snapshot = await GLView.takeSnapshotAsync(gl, {
flip: true,
});
// delete previous snapshot
if (this.state.snapshot) {
FileSystem.deleteAsync(this.state.snapshot.uri as string, { idempotent: true });
}
this.setState({ snapshot });
this.isDrawing = false;
}
return new Promise(async (resolve, reject) => {
try {
const currentStorageFileUri = await fixedStorageUri(secureStoreOptions);
if (currentStorageFileUri) {
let storageString = await FileSystem.readAsStringAsync(currentStorageFileUri);
storage = JSON.parse(storageString);
delete storage.key;
storageString = JSON.stringify(storage);
const newStorageFileUri = await generateStorageFileUri();
await FileSystem.writeAsStringAsync(newStorageFileUri, storageString);
await SecureStore.setItemAsync(storageFileUriKey, newStorageFileUri, secureStoreOptions);
await FileSystem.deleteAsync(currentStorageFileUri, { idempotent: true });
}
await SecureStore.deleteItemAsync(key, secureStoreOptions);
resolve();
} catch (e) {
reject(e);
}
});
};
static async clearCache() {
await FileSystem.deleteAsync(BASE_DIR, { idempotent: true })
await FileSystem.makeDirectoryAsync(BASE_DIR)
}
static async getCacheSize() {
static async clearCache(): Promise {
await FileSystem.deleteAsync(BASE_DIR, { idempotent: true });
await FileSystem.makeDirectoryAsync(BASE_DIR);
}
async function treeSearch(relativePath, legacyPath, newPath, resolveConflict) {
const currentNewPath = `${newPath}${relativePath}`;
const currentLegacyPath = `${legacyPath}${relativePath}`;
const legacyPathInfo = await FileSystem.getInfoAsync(currentLegacyPath);
const newPathInfo = await FileSystem.getInfoAsync(currentNewPath);
if (legacyPathInfo.exists && !newPathInfo.exists) {
await FileSystem.copyAsync({
from: currentLegacyPath,
to: currentNewPath,
});
await FileSystem.deleteAsync(currentLegacyPath);
return;
}
if (legacyPathInfo.isDirectory) {
const children = await FileSystem.readDirectoryAsync(currentLegacyPath);
for (let child of children) {
await treeSearch(relativePath + `${child}/`, legacyPath, newPath, resolveConflict);
}
}
else {
await resolveConflict(currentLegacyPath, currentNewPath);
}
}
async function doesOldFilesDirectoryContainLock(path) {