fs/promises#unlink TypeScript Examples

The following examples show how to use fs/promises#unlink. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: full_privacy.ts    From your_spotify with GNU General Public License v3.0 4 votes vote down vote up
// eslint-disable-next-line class-methods-use-this
  cleanup = async (filePaths: string[]) => {
    await Promise.all(filePaths.map((f) => unlink(f)));
  };
Example #2
Source File: privacy.ts    From your_spotify with GNU General Public License v3.0 4 votes vote down vote up
// eslint-disable-next-line class-methods-use-this
  cleanup = async (filePaths: string[]) => {
    await Promise.all(filePaths.map((f) => unlink(f)));
  };
Example #3
Source File: QBittorrent.ts    From cross-seed with Apache License 2.0 4 votes vote down vote up
async inject(
		newTorrent: Metafile,
		searchee: Searchee
	): Promise<InjectionResult> {
		if (await this.isInfoHashInClient(newTorrent.infoHash)) {
			return InjectionResult.ALREADY_EXISTS;
		}
		const buf = parseTorrent.toTorrentFile(newTorrent);
		const filename = `${newTorrent.name}.cross-seed.torrent`;
		const tempFilepath = join(tmpdir(), filename);
		await writeFile(tempFilepath, buf, { mode: 0o644 });
		try {
			const { save_path, isComplete, autoTMM, category } =
				await this.getTorrentConfiguration(searchee);

			if (!isComplete) return InjectionResult.TORRENT_NOT_COMPLETE;

			const shouldManuallyEnforceContentLayout =
				isSingleFileTorrent(newTorrent) &&
				(await this.isSubfolderContentLayout(searchee));

			const file = await fileFrom(
				tempFilepath,
				"application/x-bittorrent"
			);
			const formData = new FormData();
			formData.append("torrents", file, filename);
			formData.append("tags", "cross-seed");
			formData.append("category", category);
			if (autoTMM) {
				formData.append("autoTMM", "true");
			} else {
				formData.append("autoTMM", "false");
				formData.append("savepath", save_path);
			}
			if (shouldManuallyEnforceContentLayout) {
				formData.append("contentLayout", "Subfolder");
				formData.append("skip_checking", "false");
				formData.append("paused", "true");
			} else {
				formData.append("skip_checking", "true");
				formData.append("paused", "false");
			}

			// for some reason the parser parses the last kv pair incorrectly
			// it concats the value and the sentinel
			formData.append("foo", "bar");

			await this.request("/torrents/add", formData);

			if (shouldManuallyEnforceContentLayout) {
				await this.request(
					"/torrents/recheck",
					`hashes=${newTorrent.infoHash}`,
					X_WWW_FORM_URLENCODED
				);
				await this.request(
					"/torrents/resume",
					`hashes=${newTorrent.infoHash}`,
					X_WWW_FORM_URLENCODED
				);
			}

			unlink(tempFilepath).catch((error) => {
				logger.debug(error);
			});

			return InjectionResult.SUCCESS;
		} catch (e) {
			logger.debug({
				label: Label.QBITTORRENT,
				message: `injection failed: ${e.message}`,
			});
			return InjectionResult.FAILURE;
		}
	}