-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
266 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Temp Directory | ||
|
||
`igir` needs to write some temporary files to disk for a few reasons: | ||
|
||
- Downloading [DAT URLs](../dats/processing.md#scanning-for-dats) to disk before parsing | ||
- Extracting [some archives](../input/reading-archives.md) to disk during scanning, and when reading when extracting or [zipping](../output/writing-archives.md) | ||
|
||
Temporary files are ones that are deleted as soon as `igir` no longer needs them for processing. `igir` will also delete any leftover temporary files on exit. | ||
|
||
`igir` will use your operating system's temporary directory for these files by default. The option `--temp-dir <path>` is provided to let you change the directory, and you may want to do this for a few reasons: | ||
|
||
- Your operating system drive has minimal space available | ||
- You want to protect your operating system drive from excess wear and tear | ||
- You want to use a "RAM disk" instead of a real drive | ||
|
||
## RAM disks | ||
|
||
### :simple-windowsxp: Windows | ||
|
||
There are no tools built-in to Windows that can create a RAM disk. The open source [ImDisk Toolkit](https://sourceforge.net/projects/imdisk-toolkit/) is a popular option. | ||
|
||
### :simple-apple: macOS | ||
|
||
The built-in `diskutil` and `hdiutil` tools can be used to create and mount a RAM disk. Alex T has some instructions in a [GitHub gist](https://gist.github.com/htr3n/344f06ba2bb20b1056d7d5570fe7f596). | ||
|
||
### :simple-linux: Linux | ||
|
||
`tmpfs` is a tool that comes with most Linux distributions that is used for creating RAM disks. Oracle has [a guide](https://docs.oracle.com/cd/E18752_01/html/817-5093/fscreate-99040.html) on the tool. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os from 'node:os'; | ||
import path from 'node:path'; | ||
|
||
import moment from 'moment'; | ||
|
||
import FsPoly from '../polyfill/fsPoly.js'; | ||
import Package from './package.js'; | ||
|
||
/** | ||
* A static class of constants for temp directories, to be used widely. | ||
*/ | ||
export default class Temp { | ||
// Note: this default path is explicitly not created immediately in case it gets changed by CLI | ||
// options | ||
private static globalTempDir = path.join(os.tmpdir(), Package.NAME, moment().format('YYYYMMDD-HHmmss')); | ||
|
||
public static getTempDir(): string { | ||
return this.globalTempDir; | ||
} | ||
|
||
public static setTempDir(globalTempDir: string): void { | ||
this.globalTempDir = globalTempDir; | ||
} | ||
} | ||
|
||
process.once('beforeExit', async () => { | ||
// WARN: Jest won't call this: https://github.com/jestjs/jest/issues/10927 | ||
await FsPoly.rm(Temp.getTempDir(), { | ||
force: true, | ||
recursive: true, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.