mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
feat: enhance upload command for large uploads
- Implement persistent hash caching to avoid unnecessary file rehashing - Switch progress bars to show processed file size instead of asset count - Fix concurrency handling based on CPU count
This commit is contained in:
parent
2ce8a31b2f
commit
42a0f9f125
2 changed files with 13 additions and 44 deletions
|
|
@ -229,10 +229,10 @@ export const checkForDuplicates = async (
|
|||
}
|
||||
|
||||
const hashProgressBar = multiBar?.create(totalSize, 0, {
|
||||
message: 'Hashing files '
|
||||
message: 'Hashing files ',
|
||||
});
|
||||
const checkProgressBar = multiBar?.create(totalSize, 0, {
|
||||
message: 'Checking for duplicates'
|
||||
message: 'Checking for duplicates',
|
||||
});
|
||||
|
||||
const newFiles: string[] = [];
|
||||
|
|
@ -586,46 +586,15 @@ const updateAlbums = async (assets: Asset[], options: UploadOptionsDto) => {
|
|||
}
|
||||
};
|
||||
|
||||
const processAlbumName = (name: string, options: UploadOptionsDto): string => {
|
||||
// Only process if formatAlbumNames is enabled
|
||||
if (!options.formatAlbumNames) {
|
||||
return name;
|
||||
}
|
||||
|
||||
const originalName = name;
|
||||
let processedName = name;
|
||||
|
||||
// Remove leading non-alphabetic characters (including numbers but preserving accented letters)
|
||||
processedName = processedName.replace(/^[^\p{Letter}]+/u, '');
|
||||
|
||||
// Replace underscores and dashes with spaces, then handle multiple spaces
|
||||
processedName = processedName
|
||||
.replace(/[_\-]/g, ' ') // Convert underscores and dashes to spaces
|
||||
.replace(/\s+/g, ' ') // Replace multiple spaces with single space
|
||||
.trim(); // Remove leading/trailing spaces
|
||||
|
||||
// Capitalize first letter
|
||||
processedName = processedName.charAt(0).toUpperCase() + processedName.slice(1);
|
||||
|
||||
// Only show message once per unique original name
|
||||
if (originalName !== processedName && !processedAlbumNames.has(originalName)) {
|
||||
processedAlbumNames.add(originalName);
|
||||
console.log(`Album name changed: "${originalName}" → "${processedName}"`);
|
||||
}
|
||||
|
||||
return processedName;
|
||||
};
|
||||
|
||||
// `filepath` valid format:
|
||||
// - Windows: `D:\\test\\Filename.txt` or `D:/test/Filename.txt`
|
||||
// - Unix: `/test/Filename.txt`
|
||||
export const getAlbumName = (filepath: string, options: UploadOptionsDto) => {
|
||||
if (options.albumName) {
|
||||
return options.albumName; // Don't process custom album names
|
||||
return options.albumName;
|
||||
}
|
||||
|
||||
const dirName = path.basename(path.dirname(filepath));
|
||||
return processAlbumName(dirName, options);
|
||||
return path.basename(path.dirname(filepath));
|
||||
};
|
||||
|
||||
// `
|
||||
|
|
@ -56,7 +56,7 @@ program
|
|||
.addOption(
|
||||
new Option('-A, --album-name <n>', 'Add all assets to specified album')
|
||||
.env('IMMICH_ALBUM_NAME')
|
||||
.conflicts('album'),
|
||||
.conflicts('album')
|
||||
)
|
||||
.addOption(
|
||||
new Option('-f, --format-album-names', 'Format album names (remove leading numbers, clean up spaces and dashes)')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue