Compare commits

..

No commits in common. "8ec5d17e0916d1a36feb061111daaaeee6ec7ac1" and "80b4b379f7cd723a9bd1f38b16ace5f745a91882" have entirely different histories.

3 changed files with 16 additions and 66 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "real-debrid-downloader", "name": "real-debrid-downloader",
"version": "1.7.153", "version": "1.7.152",
"description": "Desktop downloader", "description": "Desktop downloader",
"main": "build/main/main/main.js", "main": "build/main/main/main.js",
"author": "Sucukdeluxe", "author": "Sucukdeluxe",

View File

@ -3686,16 +3686,15 @@ export class DownloadManager extends EventEmitter {
} }
} }
/** Move matching SUBTITLE companions alongside a video collected into the /** Move matching subtitle / metadata companions alongside a video that
* library. Note: .nfo / metadata files are intentionally NOT moved the * was just collected into the library. Mirrors renameCompanionFiles but
* library should contain video + subs only. .nfo stays in the extract * for cross-directory moves. */
* dir and is removed by normal cleanup. */
private async moveCompanionFiles( private async moveCompanionFiles(
sourceVideoPath: string, sourceVideoPath: string,
targetVideoPath: string, targetVideoPath: string,
pkg?: PackageEntry pkg?: PackageEntry
): Promise<void> { ): Promise<void> {
const COMPANION_EXTENSIONS = new Set([".srt", ".ass", ".ssa", ".sub", ".idx", ".vtt", ".smi"]); const COMPANION_EXTENSIONS = new Set([".srt", ".ass", ".ssa", ".sub", ".idx", ".vtt", ".smi", ".nfo"]);
const sourceDir = path.dirname(sourceVideoPath); const sourceDir = path.dirname(sourceVideoPath);
const targetDir = path.dirname(targetVideoPath); const targetDir = path.dirname(targetVideoPath);
const sourceVideoBase = path.basename(sourceVideoPath, path.extname(sourceVideoPath)); const sourceVideoBase = path.basename(sourceVideoPath, path.extname(sourceVideoPath));
@ -3777,18 +3776,17 @@ export class DownloadManager extends EventEmitter {
return null; return null;
} }
// Note: total-path length is intentionally NOT checked here. We used to // Windows MAX_PATH is 260 chars without the \\?\ long-path prefix.
// cap it at 247 chars (v1.7.151) on the assumption that paths beyond // The actual rename via renamePathWithExdevFallback ALWAYS wraps with
// Windows MAX_PATH (260) would fail or be unusable downstream. That // toWindowsLongPathIfNeeded, so paths up to ~32K technically work, but
// turned out to be ACTIVELY HARMFUL: renamePathWithExdevFallback wraps // many downstream consumers (Explorer, MediaPlayers, scripts) struggle
// every rename via toWindowsLongPathIfNeeded (\\?\ prefix), and the // beyond ~248. Use a conservative 247-char limit so the renamed file
// file ends up in the library dir after mkv-move where the parent path // remains usable. Caller will fall back to buildShortPackageFallback
// is short. Imposing a 247-char cap on the EXTRACT-dir intermediate // when this returns null.
// path threw away perfectly-good scene-release names like const SAFE_TOTAL_PATH_CHARS = 247;
// "Dr.House.S04E02.Der.Stoff.aus.dem.die.Heldin.ist.GERMAN.5.1.DL.AC3.720p.BDRiP.x264-TvR.mkv" if (candidatePath.length > SAFE_TOTAL_PATH_CHARS) {
// and replaced them with ugly "Dr.House.S04E02.mkv" via fallback. return null;
// We rely on the long-path prefix for the rename and on the 255-char }
// NTFS file-name limit above for the actual constraint.
return candidatePath; return candidatePath;
} }

View File

@ -10540,54 +10540,6 @@ describe("download manager", () => {
expect(fs.existsSync(path.join(sharedDir, "EpisodeFolder", "obfus.mkv"))).toBe(true); expect(fs.existsSync(path.join(sharedDir, "EpisodeFolder", "obfus.mkv"))).toBe(true);
}); });
it("mkv-move moves SUBTITLES to library but NOT .nfo metadata files", async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-mvcompanion-"));
tempDirs.push(root);
const extractDir = path.join(root, "extract");
const libDir = path.join(root, "library");
fs.mkdirSync(extractDir, { recursive: true });
fs.mkdirSync(libDir, { recursive: true });
const epFolder = path.join(extractDir, "Show.S01E01.GERMAN.x264-GROUP");
fs.mkdirSync(epFolder, { recursive: true });
fs.writeFileSync(path.join(epFolder, "Show.S01E01.GERMAN.x264-GROUP.mkv"), Buffer.alloc(1024, 0));
fs.writeFileSync(path.join(epFolder, "Show.S01E01.GERMAN.x264-GROUP.srt"), "subs");
fs.writeFileSync(path.join(epFolder, "Show.S01E01.GERMAN.x264-GROUP.nfo"), "info");
const manager = new DownloadManager(
{
...defaultSettings(),
token: "rd-token",
outputDir: path.join(root, "out"),
extractDir,
autoExtract: true,
collectMkvToLibrary: true,
mkvLibraryDir: libDir
},
emptySession(),
createStoragePaths(path.join(root, "state"))
);
const pkg: any = {
id: "movecomp-pkg",
name: "Show.S01.GERMAN.x264-GROUP",
outputDir: path.join(root, "out", "Show"),
extractDir,
status: "completed", itemIds: [], cancelled: false, enabled: true, priority: "normal",
createdAt: 0, updatedAt: 0, downloadStartedAt: 0, downloadCompletedAt: 0
};
await (manager as any).collectMkvFilesToLibrary("movecomp-pkg", pkg);
const libFiles = fs.readdirSync(libDir);
// Video AND subtitle moved to library.
expect(libFiles).toContain("Show.S01E01.GERMAN.x264-GROUP.mkv");
expect(libFiles).toContain("Show.S01E01.GERMAN.x264-GROUP.srt");
// .nfo MUST NOT end up in the library — that's the user-visible bug
// we are fixing. (It gets cleaned up with other residual files in
// cleanupNonMkvResidualFiles after the move; we don't care whether it
// survives in the extract dir, only that the library stays clean.)
expect(libFiles).not.toContain("Show.S01E01.GERMAN.x264-GROUP.nfo");
});
it("auto-rename also renames matching subtitle / .nfo companion files", async () => { it("auto-rename also renames matching subtitle / .nfo companion files", async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-companion-")); const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-companion-"));
tempDirs.push(root); tempDirs.push(root);