Skip to content

Commit

Permalink
detect size of remote files - fixes misskey-dev#494
Browse files Browse the repository at this point in the history
without this, remote files are assumed to have size 0 (even if we just
downloaded them!) and the range-related code won't run
  • Loading branch information
dakkar committed Apr 9, 2024
1 parent 92eec21 commit 960f4fc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/backend/src/server/FileServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ export class FileServerService {
const parts = range.replace(/bytes=/, '').split('-');
const start = parseInt(parts[0], 10);
let end = parts[1] ? parseInt(parts[1], 10) : file.file.size - 1;
console.log(end);
if (end > file.file.size) {
end = file.file.size - 1;
}
Expand Down Expand Up @@ -529,6 +528,9 @@ export class FileServerService {
if (!file.storedInternal) {
if (!(file.isLink && file.uri)) return '204';
const result = await this.downloadAndDetectTypeFromUrl(file.uri);
if (!file.size) {
file.size = (await fs.promises.stat(result.path)).size;
}
return {
...result,
url: file.uri,
Expand Down

0 comments on commit 960f4fc

Please sign in to comment.