fix: prevent ENOENT on scheduled reel publishing when local file deleted early

- facebook.ts: use resolvePublicUrl + getMediaBuffer for reels so missing local files fall back to HTTP fetch.
- scheduler.ts: only delete local video files after the last pending scheduled post for that postId is published.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Opus 4.7 committed 2026-05-04 14:08:15 +02:00
1 parent 37aba33425
commit d763be6322
2 files changed
+12 -8

No files matched your search

+3 -5
View File
@@ -72,11 +72,9 @@ export class FacebookService {
throw new Error('Reels require a video media');
}
// Upload video bytes directly — Facebook cannot fetch local/Docker URLs
const localPath = videoMedia.originalUrl.startsWith('/')
? path.join(process.cwd(), videoMedia.originalUrl)
: videoMedia.originalUrl;
const nodeBuffer = await fs.promises.readFile(localPath);
// Use public URL so getMediaBuffer can fetch via HTTP if local file is missing
const publicUrl = resolvePublicUrl(videoMedia.originalUrl);
const nodeBuffer = await this.getMediaBuffer(publicUrl);
return await this.publishVideoFromBuffer(page, nodeBuffer, post.content);
} else {
// Default to feed