WebUI: padding files are not checked by default

This commit is contained in:
Igor Katson 2025-06-09 20:33:03 +01:00
parent 963f8167de
commit acf67b2439
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 16 additions and 8 deletions

View file

@ -25,13 +25,13 @@ type FileTree = {
const newFileTree = ( const newFileTree = (
torrentDetails: TorrentDetails, torrentDetails: TorrentDetails,
stats: TorrentStats | null, stats: TorrentStats | null
): FileTree => { ): FileTree => {
const newFileTreeInner = ( const newFileTreeInner = (
name: string, name: string,
id: string, id: string,
files: TorrentFileForCheckbox[], files: TorrentFileForCheckbox[],
depth: number, depth: number
): FileTree => { ): FileTree => {
let directFiles: TorrentFileForCheckbox[] = []; let directFiles: TorrentFileForCheckbox[] = [];
let groups: FileTree[] = []; let groups: FileTree[] = [];
@ -54,7 +54,7 @@ const newFileTree = (
let sortedGroupsByName = sortBy( let sortedGroupsByName = sortBy(
Object.entries(groupsByName), Object.entries(groupsByName),
([k, _]) => k, ([k, _]) => k
); );
let childId = 0; let childId = 0;
@ -87,7 +87,7 @@ const newFileTree = (
}; };
}) })
.filter((f) => f !== null), .filter((f) => f !== null),
0, 0
); );
}; };
@ -177,7 +177,7 @@ const FileTreeComponent: React.FC<{
label={`${ label={`${
tree.name ? tree.name + ", " : "" tree.name ? tree.name + ", " : ""
} ${getTotalSelectedFiles()} files, ${formatBytes( } ${getTotalSelectedFiles()} files, ${formatBytes(
getTotalSelectedBytes(), getTotalSelectedBytes()
)}`} )}`}
name={tree.id} name={tree.id}
onChange={handleToggleTree} onChange={handleToggleTree}
@ -253,7 +253,7 @@ export const FileListInput: React.FC<{
}) => { }) => {
let fileTree = useMemo( let fileTree = useMemo(
() => newFileTree(torrentDetails, torrentStats), () => newFileTree(torrentDetails, torrentStats),
[torrentDetails, torrentStats], [torrentDetails, torrentStats]
); );
return ( return (

View file

@ -39,7 +39,15 @@ export const FileSelectionModal = (props: {
useEffect(() => { useEffect(() => {
setSelectedFiles( setSelectedFiles(
new Set(listTorrentResponse?.details.files.map((_, i) => i)), new Set(
listTorrentResponse?.details.files.flatMap((file, idx) => {
if (file.attributes.padding) {
return [];
} else {
return [idx];
}
})
)
); );
setOutputFolder(listTorrentResponse?.output_folder || ""); setOutputFolder(listTorrentResponse?.output_folder || "");
}, [listTorrentResponse]); }, [listTorrentResponse]);
@ -79,7 +87,7 @@ export const FileSelectionModal = (props: {
}, },
(e) => { (e) => {
setUploadError({ text: "Error starting torrent", details: e }); setUploadError({ text: "Error starting torrent", details: e });
}, }
) )
.finally(() => setUploading(false)); .finally(() => setUploading(false));
}; };