Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
const configRowUpdates: ConfigFile[] = [];
// Delete the old configuration files, move the new ones
for (const update of configDetails.files) {
// Delete the file if it exists
const targetLocation = `${CONFIG_DIRECTORY}${CONFIG_SUBDIRECTORIES[update.type]}${update.name}`;
const tempLocation = `${TEMP_CONFIG_DIRECTORY}${update.name}`;
const exists = await RNFS.exists(targetLocation);
if (exists) {
await RNFS.unlink(targetLocation);
}
await RNFS.moveFile(
tempLocation,
targetLocation
);
configRowUpdates.push(update);
}
// Delete temporary downloads
await RNFS.unlink(TEMP_CONFIG_DIRECTORY);
// Update config versions in database
await Database.updateConfigVersions(configRowUpdates);
await setConfigLastUpdatedAt(configDetails.lastUpdatedAt);
configurationInitialized = false;
await init();
static async upload(
logFilePath: string,
uploadPath: string,
uploadFileName: string
): Promise {
const tmpFilePath = logFilePath + '.tmp'
await RNFS.moveFile(logFilePath, tmpFilePath)
// Don't "await" here. While everything else in this async method is relatively fast, data upload can be slow
// and we don't want to block the user from using the app.
return FirebaseLogUploader.uploadLogsToFirebaseStorage(tmpFilePath, uploadPath, uploadFileName)
}
const response = await ImageResizer.createResizedImage(uri, 2000, 2000, 'JPEG', 60)
.catch((err) => {
consolelog('DEBUG camera: resize ERROR:');
consolelog(err);
onPhotoTaken(undefined, new Error('Could not take a photo: there was an error resizing the photo.'));
failed = true;
});
if (failed) { return; }
await RNFS.unlink(uri)
.catch((err) => { // not a failure
consolelog(`DEBUG camera: could not delete full-sized photo: ${err}`);
});
const destPathResized = photoPath() + '/' + destFilenameResized;
await RNFS.moveFile(response.uri, destPathResized)
.catch((err) => {
consolelog('DEBUG camera: move2 ERROR:');
consolelog(err);
onPhotoTaken(undefined, new Error('Could not take a photo: could not move the resized photo into its folder.'));
failed = true;
});
if (failed) { return; }
photo.uri = destPathResized;
photo.filename = destFilenameResized;
onPhotoTaken(photo);
};
.then(resp => {
RNFS.moveFile(resp.path(), photoPath)
.then(() => {
console.log('FILE WRITTEN!')
})
.catch(err => {
console.log(err.message)
})
})
.catch(err => {
this.refs.viewShot.capture().then(uri => {
RNFS.moveFile(uri, imagePath)
.then((success) => {
console.log('FILE MOVED!');
//this.printViewShot(imagePath)
})
.catch((err) => {
console.log(err.message);
});
});
};
async function rotateLogs () {
try {
if (await RNFS.exists(path3)) {
await RNFS.unlink(path3)
}
if (await RNFS.exists(path2)) {
await RNFS.moveFile(path2, path3)
}
if (await RNFS.exists(path1)) {
await RNFS.moveFile(path1, path2)
}
await RNFS.writeFile(path1, '')
} catch (e) {
global.clog(e)
}
}
const mlc = modelName + '.mlmodelc'
const ml = modelName + '.mlmodel'
const compiledPath = RNFS.DocumentDirectoryPath + '/' + mlc
if (await RNFS.exists(compiledPath)) {
return compiledPath
}
const toFile = RNFS.TemporaryDirectoryPath + ml
if (!(await RNFS.exists(toFile))) {
const { promise, _jobId } = RNFS.downloadFile({
fromUrl: modelURL,
toFile: toFile
})
await promise
}
const tempPath = await compileModel(toFile)
await RNFS.moveFile(tempPath, compiledPath)
return 'file://' + compiledPath
}
return new Promise((resolve, reject) => {
RNFS.moveFile(from, to)
.then(() => {
resolve(to);
});
})
})
.then(() => {
LOGi.info("Login: uploadedImage. Now start moving.");
return RNFS.moveFile(file.path, newPath);
})
.then(() => {
async function moveTextileFiles() {
const files = await RNFS.readDir(RNFS.DocumentDirectoryPath)
for (const file of files) {
if (file.path !== REPO_PATH && file.name !== 'RCTAsyncLocalStorage_V1') {
await RNFS.moveFile(file.path, `${REPO_PATH}/${file.name}`)
}
}
}