Spaces:
Paused
Paused
Download src/utils/filesystem/moveFile.mts from jbilcke-hf/VideoChain-API: direct link, hf CLI and curl.
- Browser
- Download file 567 Bytes
-
https://huggingface.co/spaces/jbilcke-hf/VideoChain-API/resolve/cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/moveFile.mts
- Command line
-
hf download hf://spaces/jbilcke-hf/VideoChain-API@cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/moveFile.mts
-
curl -L -o moveFile.mts https://huggingface.co/spaces/jbilcke-hf/VideoChain-API/resolve/cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/moveFile.mts
567 Bytes
| import { promises as fs } from "node:fs" | |
| // a function to move a file | |
| // this implementation is safe to use on a Hugging Face Space | |
| // for instance when copying from one disk to another | |
| // (we cannot use fs.rename in that case) | |
| export const moveFile = async (sourceFilePath: string, targetFilePath: string) => { | |
| await fs.copyFile(sourceFilePath, targetFilePath) | |
| console.log(`moved file from ${sourceFilePath} to ${targetFilePath}`) | |
| try { | |
| await fs.unlink(sourceFilePath) | |
| } catch (err) { | |
| console.log("moveFile: failed to cleanup (no big deal..)") | |
| } | |
| } |