Skip to content

Commit

Permalink
Cleanup thumbnails
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmccartney committed Nov 16, 2023
1 parent 1008d81 commit 63b4ebd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/pages/installation/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Docker image environment variables are given below
| AUTH_PASSWORD | ffmp3gap1 | No | String | Auth password for login |
| AUTH_KEY | averysecretkey | No | String | Private key for generating JWT tokens. Change this if you're using authentication |
| MEDIA_PATH | ./data/media | No | String | Directory to keep media in. Useful to change if media is stored in a network share |
| QUEUE_SZIE | 5 | No | Integer | Number of FFMpeg processes that can run simultaneously |
| QUEUE_SIZE | 5 | No | Integer | Number of FFMpeg processes that can run simultaneously |
| LOG_FOLDER | logs | No | String | Folder that logs are stored in |
| LOG_NAME | ffmpeg | No | String | Log file names |
| LOG_LEVEL | info | No | String | Logging level "debug", "error", "info", "http" or "warning" |
4 changes: 2 additions & 2 deletions utils/file-delete.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use strict";

const fs = require("fs");
const fs = require("fs").promises;
const path = require("path");
const logger = require("@utils/logger")(module);

module.exports = async (relativePath) => {
try {
const absolutePath = path.resolve(relativePath);
if (await fs.unlinkSync(absolutePath)) {
if (await fs.unlink(absolutePath)) {
return true;
}
return false;
Expand Down
8 changes: 7 additions & 1 deletion utils/jobManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const crypto = require("crypto");
const fileDelete = require("@utils/file-delete");

let maxQueueSize = process.env.QUEUE_SZIE || 5;
let maxQueueSize = process.env.QUEUE_SIZE || 5;
let jobs = {};

const start = (output, name = "FFmpeg Process", type = ["default"]) => {
Expand Down Expand Up @@ -36,12 +37,17 @@ const update = (hash, update) => {
const end = (hash, kill = true) => {
if (jobs[hash]) {
const job = jobs[hash];

if (kill) {
process.kill(jobs[hash].pid, "SIGINT");
}

job.ended = new Date();
job.duration = job.ended - job.started;
delete jobs[hash];

fileDelete(`data/thumbnail/${job.jobId}.png`);

return job;
} else {
return { error: "Job does not exist." };
Expand Down

0 comments on commit 63b4ebd

Please sign in to comment.