mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
fix(storage): handle null values in file sorting to prevent crashes
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, List
|
from typing import Any, List
|
||||||
|
|
||||||
@@ -68,9 +69,9 @@ def list(fileitem: schemas.FileItem,
|
|||||||
file_list = StorageChain().list_files(fileitem)
|
file_list = StorageChain().list_files(fileitem)
|
||||||
if file_list:
|
if file_list:
|
||||||
if sort == "name":
|
if sort == "name":
|
||||||
file_list.sort(key=lambda x: x.name)
|
file_list.sort(key=lambda x: x.name or "")
|
||||||
else:
|
else:
|
||||||
file_list.sort(key=lambda x: x.modify_time, reverse=True)
|
file_list.sort(key=lambda x: x.modify_time or datetime.min, reverse=True)
|
||||||
return file_list
|
return file_list
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user