feat: many things (#351)

* remove source from final image

* move check state to ClearStorage

* use inspect for fancy colors

* newlines are now possible! yay!

* Catch user's leave if uploading

* feat?: Temp directory can be specified by the user.
Default is /tmp/zipline (or os equivalent)

* fix: ignore onDash config, use only ?compress query

---------

Co-authored-by: dicedtomato <35403473+diced@users.noreply.github.com>
This commit is contained in:
Jayvin Hernandez
2023-03-31 22:25:00 -07:00
committed by GitHub
parent bc58c1b56e
commit bf40fa9cd2
16 changed files with 90 additions and 38 deletions

View File

@@ -1,6 +1,7 @@
import { FastifyInstance } from 'fastify';
import fastifyPlugin from 'fastify-plugin';
import { mkdir } from 'fs/promises';
import { existsSync } from 'fs';
import { mkdir, readdir } from 'fs/promises';
import type { Config } from 'lib/config/Config';
async function configPlugin(fastify: FastifyInstance, config: Config) {
@@ -16,7 +17,9 @@ async function configPlugin(fastify: FastifyInstance, config: Config) {
.error(
'The config file is located at `.env.local`, or if using docker-compose you can change the variables in the `docker-compose.yml` file.'
)
.error('It is recomended to use a secret that is alphanumeric and randomized.')
.error(
'It is recomended to use a secret that is alphanumeric and randomized. If you include special characters, surround the secret with quotes.'
)
.error('A way you can generate this is through a password manager you may have.');
process.exit(1);
@@ -26,6 +29,24 @@ async function configPlugin(fastify: FastifyInstance, config: Config) {
await mkdir(config.datasource.local.directory, { recursive: true });
}
if (!existsSync(config.core.temp_directory)) {
await mkdir(config.core.temp_directory, { recursive: true });
} else {
const files = await readdir(config.core.temp_directory);
if (
files.filter((x: string) => x.startsWith('zipline_partial_') || x.startsWith('zipline-exif-read-'))
.length > 0
)
fastify.logger
.error("Found temporary files in Zipline's temp directory.")
.error('This can happen if Zipline crashes or is stopped while chunking a file.')
.error(
'If you are sure that no files are currently being processed, you can delete the files in the temp directory.'
)
.error('The temp directory is located at: ' + config.core.temp_directory)
.error('If you are unsure, you can safely ignore this message.');
}
return;
}