Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(exist => {
// Check if the file is present in the assets folder.
if (exist) {
// File exists so it can be extracted to the external storage directory.
RNFS.copyFileAssets(assetFile, "/sdcard/" + assetFile)
.then(() => {
// File copied successfully from assets folder to external storage directory.
callback();
})
.catch(error => {
console.log(error);
});
} else {
// File does not exist, it should never happen.
throw new Error(
assetFile +
" couldn't be extracted as it was not found in the project assets folder."
);
}
})
.catch(error => {
async function androidResourcePath(resourceName) {
var destinationPath = RNFS.CachesDirectoryPath + '/' + resourceName;
await RNFS.copyFileAssets(resourceName, destinationPath).catch((err) => {
console.log('Failed to copy android resource: ' + resourceName + ', err message: ' + err.message + ', err code: ' + err.code);
return undefined;
});
return destinationPath;
}
componentWillMount() {
RNFS.unlink(RNFS.DocumentDirectoryPath + "/nkjv.realm");
RNFS.unlink(RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
if (Platform.OS == "android") {
RNFS.copyFileAssets("nkjv.realm", RNFS.DocumentDirectoryPath + "/nkjv.realm");
RNFS.copyFileAssets("nkjv.realm.lock", RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
} else {
try {
RNFS.copyFile(RNFS.MainBundlePath + "/nkjv.realm", RNFS.DocumentDirectoryPath + "/nkjv.realm");
RNFS.copyFile(RNFS.MainBundlePath + "/nkjv.realm.lock", RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
} catch (e) {
console.log("FILE ALREADY EXISTS");
}
}
}
_onShowSearch() {
componentWillMount() {
RNFS.unlink(RNFS.DocumentDirectoryPath + "/nkjv.realm");
RNFS.unlink(RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
if (Platform.OS == "android") {
RNFS.copyFileAssets("nkjv.realm", RNFS.DocumentDirectoryPath + "/nkjv.realm");
RNFS.copyFileAssets("nkjv.realm.lock", RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
} else {
try {
RNFS.copyFile(RNFS.MainBundlePath + "/nkjv.realm", RNFS.DocumentDirectoryPath + "/nkjv.realm");
RNFS.copyFile(RNFS.MainBundlePath + "/nkjv.realm.lock", RNFS.DocumentDirectoryPath + "/nkjv.realm.lock");
} catch (e) {
console.log("FILE ALREADY EXISTS");
}
}
}
_onShowSearch() {
() => {
if (Platform.OS == "android") {
RNFS.copyFileAssets(`${book}.realm.lock`, RNFS.DocumentDirectoryPath + `/${book}.realm.lock`);
RNFS.copyFileAssets(`${book}.realm`, RNFS.DocumentDirectoryPath + `/${book}.realm`).then(() => {
this.loadPassage();
this._bottomSheet.close();
});
} else {
try {
RNFS.copyFile(
RNFS.MainBundlePath + `/${book}.realm.lock`,
RNFS.DocumentDirectoryPath + `/${book}.realm.lock`
);
RNFS.copyFile(
RNFS.MainBundlePath + `/${book}.realm`,
RNFS.DocumentDirectoryPath + `/${book}.realm`
).then(() => {
this.loadPassage();
this._bottomSheet.close();
});
() => {
if (Platform.OS == "android") {
RNFS.copyFileAssets(`${book}.realm.lock`, RNFS.DocumentDirectoryPath + `/${book}.realm.lock`);
RNFS.copyFileAssets(`${book}.realm`, RNFS.DocumentDirectoryPath + `/${book}.realm`).then(() => {
this.loadPassage();
this._bottomSheet.close();
});
} else {
try {
RNFS.copyFile(
RNFS.MainBundlePath + `/${book}.realm.lock`,
RNFS.DocumentDirectoryPath + `/${book}.realm.lock`
);
RNFS.copyFile(
RNFS.MainBundlePath + `/${book}.realm`,
RNFS.DocumentDirectoryPath + `/${book}.realm`
).then(() => {
this.loadPassage();
this._bottomSheet.close();
loadVersion(payload, rootState) {
const activeVersion = rootState.bible.activeVersion.value;
if (Platform.OS == 'ios') {
RNFS.copyFile(
RNFS.MainBundlePath + `/${activeVersion}.realm`,
RNFS.DocumentDirectoryPath + `/${activeVersion}.realm`,
);
} else {
RNFS.copyFileAssets(`${activeVersion}.realm`, `${RNFS.DocumentDirectoryPath}/${activeVersion}.realm`);
}
},
fetchVerses(payload, rootState) {