mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-09-24 15:49:09 +00:00
feat(uploadService): add fallback handling for compressed upload failures
- Add try-catch wrapper around uploadFoldersCompressed to handle compression failures gracefully - Implement fallback to regular upload when compressed upload is not supported - Check for failed folders in compressed results and trigger full fallback if needed - Return error indicator from uploadFoldersCompressed instead of attempting inline fallback - Improve error logging to distinguish between compression support issues and other failures - Ensure all entries are uploaded via regular upload path when compression is unavailable - This prevents upload failures when the server doesn't support compressed folder uploads
This commit is contained in:
+29
-17
@@ -369,7 +369,26 @@ export async function uploadFromFileList(
|
||||
|
||||
if (folderEntries.length > 0) {
|
||||
console.log('[uploadFromFileList] Using compressed upload for folders:', folderEntries.map(([key]) => key));
|
||||
return uploadFoldersCompressed(folderEntries, entries, targetPath, sftpId, callbacks, controller);
|
||||
try {
|
||||
const compressedResults = await uploadFoldersCompressed(folderEntries, entries, targetPath, sftpId, callbacks, controller);
|
||||
|
||||
// Check if any folders failed due to lack of compression support
|
||||
const failedFolders = compressedResults.filter(result =>
|
||||
!result.success && result.error === "Compressed upload not supported - fallback needed"
|
||||
);
|
||||
|
||||
if (failedFolders.length > 0) {
|
||||
console.log('[uploadFromFileList] Some folders failed compressed upload, falling back to regular upload');
|
||||
// Fall back to regular upload for all entries
|
||||
return uploadEntries(entries, targetPath, sftpId, isLocal, bridge, joinPath, callbacks, controller);
|
||||
}
|
||||
|
||||
return compressedResults;
|
||||
} catch (error) {
|
||||
console.log('[uploadFromFileList] Compressed upload failed, falling back to regular upload:', error);
|
||||
// Fall back to regular upload
|
||||
return uploadEntries(entries, targetPath, sftpId, isLocal, bridge, joinPath, callbacks, controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -915,22 +934,15 @@ async function uploadFoldersCompressed(
|
||||
const support = await checkCompressedUploadSupport(sftpId);
|
||||
if (!support.supported) {
|
||||
console.log('[uploadFoldersCompressed] Compressed upload not supported, falling back to regular upload');
|
||||
// Fall back to regular upload for this folder
|
||||
const folderResults = await uploadEntries(
|
||||
entries,
|
||||
targetPath,
|
||||
sftpId,
|
||||
false,
|
||||
// We need to create a minimal bridge for fallback
|
||||
{
|
||||
mkdirSftp: async () => {},
|
||||
writeSftpBinary: async () => {},
|
||||
} as UploadBridge,
|
||||
(base: string, name: string) => `${base}/${name}`,
|
||||
callbacks,
|
||||
controller
|
||||
);
|
||||
results.push(...folderResults);
|
||||
// Fall back to regular upload for this folder using the real bridge and config
|
||||
// We need to get the original config from the parent function
|
||||
// Since we don't have access to the original config here, we'll return an error
|
||||
// and let the caller handle the fallback
|
||||
results.push({
|
||||
fileName: folderName,
|
||||
success: false,
|
||||
error: "Compressed upload not supported - fallback needed"
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user