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 17, 2025
2 parents afb3826 + 353a687 commit 9dc1c78
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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
### Fixed
- Fix the case when the uploaded video original is for some reason missing at
the time of the _finalizeCreation_ call.

## [2.23.6] - 2025-02-16
### Added
- The `has:` search operator now supports the _video_ media type and has a
Expand Down
27 changes: 24 additions & 3 deletions app/models/attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { currentConfig } from '../support/app-async-context';
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';

const mvAsync = util.promisify(mv);

Expand Down Expand Up @@ -216,6 +217,11 @@ export function addModel(dbAdapter) {
async finalizeCreation(filePath) {
debug(`finalizing creation of ${this.id}`);

if (!this.meta.inProgress) {
debugError(`attachment ${this.id} is already finalized, aborting`);
return;
}

let processTime = 0;

try {
Expand All @@ -239,10 +245,25 @@ export function addModel(dbAdapter) {
// Update data
await dbAdapter.updateAttachment(this.id, { ...mediaData, updatedAt: 'now' });
} catch (err) {
debugError(`finalizeCreation error: ${err.message}, treat file as 'general' type`);
debugError(
`finalizeCreation error for ${this.id}: ${err.message}, treat file as 'general' type`,
);

let fileSize = null;
let { fileName } = this;

try {
const st = await fs.stat(filePath);
fileSize = st.size;
} catch {
debugError(`file ${filePath} doesn't exist anymore, creating a stab`);
const stubContent = 'The original file was lost';
await fs.writeFile(filePath, stubContent);
fileSize = Buffer.byteLength(stubContent);
fileName = setExtension(fileName, 'txt');
}

const { size: fileSize } = await fs.stat(filePath);
const ext = extname(this.fileName)
const ext = extname(fileName)
.toLowerCase()
.replace(/[^a-z0-9_]/g, '') // Only the restricted set of chars is allowed
.slice(0, 6); // Limit the length of the extension
Expand Down
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.7",
"version": "2.24.0",
"private": true,
"scripts": {
"start": "cross-env TZ=UTC yarn babel index.js",
Expand Down

0 comments on commit 9dc1c78

Please sign in to comment.