Spaces:
Paused
Paused
Download src/utils/filesystem/moveFileFromTmpToPending.mts from jbilcke-hf/VideoChain-API: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/jbilcke-hf/VideoChain-API/resolve/cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/moveFileFromTmpToPending.mts
- Command line
-
hf download hf://spaces/jbilcke-hf/VideoChain-API@cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/moveFileFromTmpToPending.mts
-
curl -L -o moveFileFromTmpToPending.mts https://huggingface.co/spaces/jbilcke-hf/VideoChain-API/resolve/cd4ee95e1e76fb32012ff8216dcaad5839176a8a/src/utils/filesystem/moveFileFromTmpToPending.mts
721 Bytes
| import path from "node:path" | |
| import tmpDir from "temp-dir" | |
| import { pendingFilesDirFilePath } from "../../config.mts" | |
| import { moveFile } from "./moveFile.mts" | |
| // a function to move a file to the pending file directory | |
| // 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 moveFileFromTmpToPending = async (tmpFileName: string, pendingFileName?: string) => { | |
| if (!pendingFileName) { | |
| pendingFileName = tmpFileName | |
| } | |
| const tmpFilePath = path.join(tmpDir, tmpFileName) | |
| const pendingFilePath = path.join(pendingFilesDirFilePath, pendingFileName) | |
| await moveFile(tmpFilePath, pendingFilePath) | |
| } |