How to use the react-native-fs.unlink function in react-native-fs

To help you get started, we’ve selected a few react-native-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github josephroquedev / campus-guide / old / js / util / Configuration.js View on Github external
async function _deleteConfiguration(): Promise < void > {
  try {
    const configVersions : Array < Object > = await Database.getConfigVersions();
    const clearVersions: Array < Object > = [];

    if (configVersions == null) {
      return;
    }

    for (let i = 0; i < configVersions.length; i++) {
      try {
        const dir = CONFIG_SUBDIRECTORIES[configVersions[i].type];
        await RNFS.unlink(CONFIG_DIRECTORY + dir + configVersions[i].name);
      } catch (e) {
        // do nothing - file doesn't exist
      }

      clearVersions.push({
        name: configVersions[i].name,
        type: configVersions[i].type,
        version: 0,
      });
    }

    await Database.updateConfigVersions(clearVersions);
    await RNFS.unlink(CONFIG_DIRECTORY);
  } catch (err) {
    console.log('Error accessing database while clearing versions.', err);
  }
github josephroquedev / campus-guide / old / js / util / Configuration.js View on Github external
}

      await RNFS.moveFile(
        TEMP_CONFIG_DIRECTORY + configurationUpdates[i].name,
        CONFIG_DIRECTORY + CONFIG_SUBDIRECTORIES[configurationUpdates[i].type] + configurationUpdates[i].name
      );

      configRowUpdates.push({
        name: configurationUpdates[i].name,
        type: configurationUpdates[i].type,
        version: configurationUpdates[i].newVersion,
      });
    }

    // Delete temporary downloads
    await RNFS.unlink(TEMP_CONFIG_DIRECTORY);

    // Update config versions in database
    await Database.updateConfigVersions(configRowUpdates);

    university = null;
    await module.exports.init();
  } catch (e) {
    throw e;
  }
}
github josephroquedev / campus-guide / src / util / Configuration.ts View on Github external
if (!__DEV__) {
    return;
  }

  try {
    const configVersions = await Database.getConfigVersions();
    const clearVersions: ConfigFile[] = [];

    if (configVersions == undefined) {
      return;
    }

    for (const configVersion of configVersions) {
      try {
        const dir = CONFIG_SUBDIRECTORIES[configVersion.type];
        await RNFS.unlink(CONFIG_DIRECTORY + dir + configVersion.name);
      } catch (e) {
        // do nothing - file doesn't exist
      }

      clearVersions.push({
        name: configVersion.name,
        size: 0,
        type: configVersion.type,
        url: '',
        version: 0,
      });
    }

    await Database.updateConfigVersions(clearVersions);

    const exists = await RNFS.exists(CONFIG_DIRECTORY);
github EkoLabs / react-native-background-downloader / testApp / App.js View on Github external
.done(async() => {
                try {
                    console.log(`Finished downloading: ${task.id}, deleting it...`);
                    await RNFS.unlink(filePath);
                    console.log(`Deleted ${task.id}`);
                } catch (e) {
                    console.error(e);
                }
                delete this.idsToData[task.id];
                this.saveDownloads();
                this.setState(produce(draft => {
                    delete draft.downloadsData[task.id];
                    draft.downloads.splice(draft.downloads.indexOf(task.id), 1);
                }));
            })
            .error(err => {
github josephroquedev / campus-guide / src / util / Configuration.ts View on Github external
}

      clearVersions.push({
        name: configVersion.name,
        size: 0,
        type: configVersion.type,
        url: '',
        version: 0,
      });
    }

    await Database.updateConfigVersions(clearVersions);

    const exists = await RNFS.exists(CONFIG_DIRECTORY);
    if (exists) {
      await RNFS.unlink(CONFIG_DIRECTORY);
    }
  } catch (err) {
    console.error('Error accessing database while clearing versions.', err);
  }
}
github sonnylazuardi / bibleify-mobile / old / src / app.js View on Github external
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() {
github celo-org / celo-monorepo / packages / mobile / src / geth / geth.ts View on Github external
async function deleteFileIfExists(path: string) {
  try {
    const gethLockFileExists = await RNFS.exists(path)
    if (gethLockFileExists) {
      Logger.debug('Geth@deleteFileIfExists', `Dir ${path} exists. Attempting to delete`)
      await RNFS.unlink(path)
      return true
    } else {
      Logger.debug('Geth@deleteFileIfExists', `Dir ${path} does not exist`)
      return true
    }
  } catch (error) {
    Logger.error('Geth@deleteFileIfExists', `Failed to delete ${path}`, error)
    return false
  }
}
github jayesbe / react-native-cacheable-image / image.js View on Github external
.then((res) => {
            if (res) {
                RNFS
                .unlink(filePath)
                .catch((err) => {});
            }
        });
    }
github cliqz-oss / browser-core / platforms / react-native / persistent-map.es View on Github external
async delete(key) {
    const file = await this._getFileForKey(key);
    if (file) {
      return RNFS.unlink(`${this._mapDir}/${file}`);
    }
    return Promise.resolve();
  }