Skip to content

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

NameTypeDescription
dbDatabase
Source

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

NameTypeDescription
operationOperation
Source

automatic

def automatic() -> Set[str]:

The ids of the operations made by the automatic sorting.

Source

undo_checked

def undo_checked(operation_id: str, index: Any = None) -> UndoReport:

undo(), for an operation and a file that exist.

Parameters

NameTypeDefaultDescription
operation_idstr
indexAnyNone

Raises

Source

UnknownOperation

class UnknownOperation

Bases: LookupError

No operation of the history has this id, or no file this index.

Source

Functions

describe

def describe(operation: Operation, auto: bool = False) -> Dict[str, Any]:

An operation as the History page shows it.

Parameters

NameTypeDefaultDescription
operationOperationThe operation.
autoboolFalseMade by the automatic sorting.
Source

forget_processed

def forget_processed(db: Database, paths: List[str]) -> int:

Analyze these files again: they are no longer processed.

Parameters

NameTypeDescription
dbDatabase
pathsList[str]

Returns

  • intHow many were processed.
Source

processed_files

def processed_files(db: Database) -> List[Dict[str, Any]]:

The files processed, newest first: the filter "already processed".

Parameters

NameTypeDescription
dbDatabase
Source

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

NameTypeDescription
pathstr
sizeint
mtime_nsint
Source

undo_report

def undo_report(report: UndoReport) -> Dict[str, Any]:

What an undo did, for the answer of the request.

Parameters

NameTypeDescription
reportUndoReport
Source

Attributes

NameValue
MEDIA_TYPE_OF_KIND{'movie': 'movies', 'tv_series': 'tv', 'episode': 'tv', 'album': 'music', 'track': 'music', 'book': 'books', 'game': 'games'}
Built with Kiln