Skip to content

Commit

Permalink
Merge stable into release
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmz committed Feb 19, 2025
2 parents 37df11c + 0d316bc commit 51786da
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.24.0] - Not released

## [2.23.8] - 2025-02-17
### Fixed
- Fix the case when the uploaded video original is for some reason missing at
Expand Down
36 changes: 8 additions & 28 deletions app/models/attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { createPrepareVideoJob } from '../jobs/attachment-prepare-video';
import { PubSub as pubSub } from '../models';
import { TooManyRequestsException } from '../support/exceptions';
import { setExtension } from '../support/media-files/file-ext';
import { unlinkIfExists } from '../support/unlink-if-exists';

const mvAsync = util.promisify(mv);

Expand Down Expand Up @@ -363,17 +364,7 @@ export function addModel(dbAdapter) {
} finally {
// Remove the rest of local files
const paths = [originalPath, ...Object.values(files).map(({ path }) => path)];
await Promise.all(
paths.map((path) => {
try {
fs.unlink(path);
} catch (err) {
if (err.code !== 'ENOENT') {
throw err;
}
}
}),
);
await Promise.all(paths.map((path) => unlinkIfExists(path)));
}
}

Expand Down Expand Up @@ -544,16 +535,7 @@ export function addModel(dbAdapter) {
);
} else {
await Promise.all(
this.allRelFilePaths().map(async (path) => {
try {
await fs.unlink(storageConfig.rootDir + path);
} catch (err) {
// It is ok if file isn't found
if (err.code !== 'ENOENT') {
throw err;
}
}
}),
this.allRelFilePaths().map((path) => unlinkIfExists(storageConfig.rootDir + path)),
);
}
}
Expand Down Expand Up @@ -652,14 +634,12 @@ export function addModel(dbAdapter) {
return true;
} finally {
try {
await fs.unlink(localFile);
await unlinkIfExists(localFile);
} catch (err) {
if (err.code !== 'ENOENT') {
debugError(`sanitizeOriginal: cannot remove temporary file: ${localFile}`);
Raven.captureException(err, {
extra: { err: `sanitizeOriginal: cannot remove temporary file: ${localFile}` },
});
}
debugError(`sanitizeOriginal: cannot remove temporary file: ${localFile}`);
Raven.captureException(err, {
extra: { err: `sanitizeOriginal: cannot remove temporary file: ${localFile}` },
});
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions app/support/is-no-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Type safe check for ENOENT errors
*/
export function isNoEntryError(error: unknown): error is NodeJS.ErrnoException {
return error instanceof Error && 'code' in error && error.code === 'ENOENT';
}
13 changes: 13 additions & 0 deletions app/support/unlink-if-exists.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { unlink } from 'fs/promises';

import { isNoEntryError } from './is-no-entry';

export async function unlinkIfExists(path: string) {
try {
await unlink(path);
} catch (err) {
if (!isNoEntryError(err)) {
throw err;
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "freefeed-server",
"description": "FreeFeed is an open source FriendFeed clone (yes, it is free and open!) based on Pepyatka open-source FriendFeed clone (yes, that one is also free and open). Basically, this is a social real-time feed aggregator that allows you to share cute kittens, coordinate upcoming events, discuss any other cool stuff on the Internet or setup a private Pepyatka instance in your company.",
"homepage": "https://freefeed.net",
"version": "2.23.9",
"version": "2.24.0",
"private": true,
"scripts": {
"start": "cross-env TZ=UTC yarn babel index.js",
Expand Down

0 comments on commit 51786da

Please sign in to comment.