sok.server.history
The rename history of S.O.K Server, in the database, and the files already processed.
The history of the desktop app (sok.core.history) records the renames and undoes them; only where it keeps them changes: the history table of sok.db instead of history.json. Each operation is one row, newest first (position 0), with the media type of its tab.
An operation made by the automatic sorting is told apart by its rename: the renames table keeps whether it was automatic, and the result names the operation.
A file renamed is also "processed": with a hard link or a copy it stays in the downloads, and the next analyses leave it out while it keeps its path, size and date. The processed table is not limited to the 100 operations of the history. It is written in the same transaction as the history: a rename adds its files, an undo removes them.
History
class History(db: Database)Bases: HistoryStore
The operations of the history, newest first, saved in the database.
Parameters
| Name | Type | Description |
|---|---|---|
db | Database |
add
def add(operation: Operation) -> None:Add an operation, and its files still at their old place (linked or copied) to the files processed.
Parameters
| Name | Type | Description |
|---|---|---|
operation | Operation |
automatic
def automatic() -> Set[str]:The ids of the operations made by the automatic sorting.
Sourceundo_checked
def undo_checked(operation_id: str, index: Any = None) -> UndoReport:undo(), for an operation and a file that exist.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
operation_id | str | ||
index | Any | None |
Raises
UnknownOperationNo operation has this id, or no file this index.
UnknownOperation
class UnknownOperationBases: LookupError
No operation of the history has this id, or no file this index.
SourceFunctions
describe
def describe(operation: Operation, auto: bool = False) -> Dict[str, Any]:An operation as the History page shows it.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
operation | Operation | The operation. | |
auto | bool | False | Made by the automatic sorting. |
forget_processed
def forget_processed(db: Database, paths: List[str]) -> int:Analyze these files again: they are no longer processed.
Parameters
| Name | Type | Description |
|---|---|---|
db | Database | |
paths | List[str] |
Returns
intHow many were processed.
processed_files
def processed_files(db: Database) -> List[Dict[str, Any]]:The files processed, newest first: the filter "already processed".
Parameters
| Name | Type | Description |
|---|---|---|
db | Database |
unchanged
def unchanged(path: str, size: int, mtime_ns: int) -> bool:Whether a file still has the size and the date it was processed with.
Parameters
| Name | Type | Description |
|---|---|---|
path | str | |
size | int | |
mtime_ns | int |
undo_report
def undo_report(report: UndoReport) -> Dict[str, Any]:What an undo did, for the answer of the request.
Parameters
| Name | Type | Description |
|---|---|---|
report | UndoReport |
Attributes
| Name | Value |
|---|---|
MEDIA_TYPE_OF_KIND | {'movie': 'movies', 'tv_series': 'tv', 'episode': 'tv', 'album': 'music', 'track': 'music', 'book': 'books', 'game': 'games'} |