Sharkey/packages/backend/src/services/drive
Johann150 e27c6abaea
refactor: temporary files (#8713)
* simplify temporary files for thumbnails

Because only a single file will be written to the directory, creating a
separate directory seems unnecessary. If only a temporary file is created,
the code from `createTemp` can be reused here as well.

* refactor: deduplicate code for temporary files/directories

To follow the DRY principle, the same code should not be duplicated
across different files. Instead an already existing function is used.

Because temporary directories are also create in multiple locations,
a function for this is also newly added to reduce duplication.

* fix: clean up identicon temp files

The temporary files for identicons are not reused and can be deleted
after they are fully read. This condition is met when the stream is closed
and so the file can be cleaned up using the events API of the stream.

* fix: ensure cleanup is called when download fails

* fix: ensure cleanup is called in error conditions

This covers import/export queue jobs and is mostly just wrapping all
code in a try...finally statement where the finally runs the cleanup.

* fix: use correct type instead of `any`
2022-05-25 16:50:22 +09:00
..
add-file.ts enhance: ドライブに画像ファイルをアップロードするときオリジナル画像を破棄してwebpublicのみ保持するオプション (#8216) 2022-04-28 11:14:03 +09:00
delete-file.ts delete needless instance drive columns 2022-03-07 21:20:14 +09:00
generate-video-thumbnail.ts refactor: temporary files (#8713) 2022-05-25 16:50:22 +09:00
image-processor.ts enhance: ドライブに画像ファイルをアップロードするときオリジナル画像を破棄してwebpublicのみ保持するオプション (#8216) 2022-04-28 11:14:03 +09:00
internal-storage.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
logger.ts refactor: Use ESM (#8358) 2022-02-27 11:07:39 +09:00
s3.ts fix esm 2022-03-01 03:34:40 +09:00
upload-from-url.ts refactor: temporary files (#8713) 2022-05-25 16:50:22 +09:00