filesafe/scripts
Bobby Wibowo 38e673226f
fix: inconsistent size field in DB !! yarn migrate
we used to store number directly into the string size field, and
during the conversion it seemed to always add ".0" at the final string,
probably because the driver or sqlite3 itself assumes float

please run yarn migrate after pulling this commit
if you skip converting the DB, file duplicates check will fail to
function

and in the future im planning to do size statistics in bigint, which
will also fail if not converted
2022-06-29 14:35:00 +07:00
..
bump-versions.js Added scripts/rebuild-hashes.js 2020-12-27 18:16:01 +07:00
cf-purge.js Added scripts/rebuild-hashes.js 2020-12-27 18:16:01 +07:00
clean-up.js feat: initiate db connection only once 2022-06-04 04:21:56 +07:00
delete-expired.js feat: console logs of temp uploads check ups 2022-05-07 02:01:33 +07:00
migrate.js fix: inconsistent size field in DB !! yarn migrate 2022-06-29 14:35:00 +07:00
README.md chore: README 2022-06-22 17:20:42 +07:00
rebuild-hashes.js feat: initiate db connection only once 2022-06-04 04:21:56 +07:00
thumbs.js feat: initiate db connection only once 2022-06-04 04:21:56 +07:00

README

cf-purge.js

$ yarn cf-purge
$ node ./scripts/cf-purge.js
Purge Cloudflare's cache.

Usage:
node scripts/cf-purge.js ...filename

filename:
Upload names separated by space (will automatically include their thumbs if available).

clean-up.js

$ yarn clean-up -h
$ node ./scripts/clean-up.js -h
Clean up files that are not in the database.

Usage:
node scripts/clean-up.js [mode=0|1|2]

mode:
0 = Only list names of files that are not in the database.
1 = Clean up the files.

delete-expired.js

$ yarn delete-expired -h
$ node ./scripts/delete-expired.js -h
Bulk delete expired files.

Usage:
node scripts/delete-expired.js [mode=0|1|2]

mode:
0 = Only list names of the expired files.
1 = Delete expired files (output file names).
2 = Delete expired files (no output).

rebuild-hashes.js

$ yarn rebuild-hashes -h
$ node ./scripts/rebuild-hashes.js -h
Rebuild file hashes.

Usage:
node scripts/rebuild-hashes.js <mode=0|1|2>

mode:
0 = Dry run (recalculate hashes, print them, but do NOT store to DB).
1 = Recalculate hashes and store to DB.
2 = Verbose (recalculate hashes, print them, and store to DB).

thumbs.js

Thumbnails will not be automatically generated for files that were uploaded before enabling thumbnails generation in the config file.

To generate thumbnails for those files, you can use yarn thumbs.

$ yarn thumbs
$ node ./scripts/thumbs.js
Generate thumbnails.

Usage:
node scripts/thumbs.js <mode=1|2|3> [force=0|1] [verbose=0|1] [cfcache=0|1]

mode    : 1 = images only, 2 = videos only, 3 = both images and videos
force   : 0 = no force (default), 1 = overwrite existing thumbnails
verbose : 0 = only print missing thumbs (default), 1 = print all, 2 = print nothing
cfcache : 0 = do not clear cloudflare cache (default), 1 = clear cloudflare cache

For example, if you only want to generate thumbnails for image files without overwriting existing ones, you can run yarn thumbs 1, or if you want to generate thumbnails for both image and video files, while also overwriting existsing ones, you can run yarn thumbs 3 1.

You will also need to use this script to overwrite existing thumbnails if you want to change thumbnail size.

bump-versions.js

[...]