feat: apply per-account Premium 4GB upload limit to bypass repacking

This commit is contained in:
2026-05-02 23:28:00 +02:00
parent 579276ee2d
commit 4f59d19ac2
2 changed files with 13 additions and 9 deletions

View File

@@ -342,7 +342,9 @@ export async function runWorkerForAccount(
id: account.id,
phone: account.phone,
});
void isPremium; // will be used in Task 6 for upload limits
const maxUploadSize = isPremium
? 3950n * 1024n * 1024n
: BigInt(config.maxPartSizeMB) * 1024n * 1024n;
// Load all chats into TDLib's local cache using loadChats (the recommended API).
// Without this, getChat/searchChatMessages fail with "Chat not found".
@@ -455,7 +457,7 @@ export async function runWorkerForAccount(
topicCreator: null,
sourceTopicId: null,
accountLog,
maxUploadSize: BigInt(config.maxPartSizeMB) * 1024n * 1024n,
maxUploadSize,
};
if (forum) {
@@ -1116,7 +1118,7 @@ async function processOneArchiveSet(
});
const concatPath = path.join(setDir, `${archiveSet.baseName}.concat`);
await concatenateFiles(tempPaths, concatPath);
splitPaths = await byteLevelSplit(concatPath);
splitPaths = await byteLevelSplit(concatPath, ctx.maxUploadSize);
uploadPaths = splitPaths;
// Clean up the concat intermediate file
await unlink(concatPath).catch(() => {});
@@ -1130,7 +1132,7 @@ async function processOneArchiveSet(
currentFileNum: setIdx + 1,
totalFiles: totalSets,
});
splitPaths = await byteLevelSplit(tempPaths[0]);
splitPaths = await byteLevelSplit(tempPaths[0], ctx.maxUploadSize);
uploadPaths = splitPaths;
}