cloud_server.db.files_metadata_database_manager

Files metadata database manager.

Classes

FileMetadataDB(*[, id, uploaded_at, updated_at])

Files metadata table.

FilesMetadataDatabaseManager()

Manager class for files metadata database operations.

class cloud_server.db.files_metadata_database_manager.FileMetadataDB(*, id=None, filename, parent_directory, mime_type, size, uploaded_at=<factory>, updated_at=<factory>)[source]

Files metadata table.

id: int | None
filename: str
parent_directory: str
mime_type: str
size: int
uploaded_at: int
updated_at: int
classmethod from_file_metadata(file_metadata)[source]

Create a FileMetadataDB instance from a FileMetadata.

Return type:

FileMetadataDB

to_file_metadata()[source]

Convert the database model to a FileMetadata.

Return type:

FileMetadata

update_from_file_metadata(file_metadata)[source]

Update the database model fields from a FileMetadata.

Return type:

None

__init__(**data)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_config: ClassVar[ConfigDict] = {'from_attributes': True, 'read_from_attributes': True, 'read_with_orm_mode': True, 'registry': PydanticUndefined, 'table': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class cloud_server.db.files_metadata_database_manager.FilesMetadataDatabaseManager[source]

Manager class for files metadata database operations.

__init__()[source]

Initialize the FilesMetadataDatabaseManager with the given database configuration.

db_config: ServerDatabaseConfig
property db_url: str

Get the database URL.

list_files()[source]

Public method to list all file metadata entries.

Return type:

list[FileMetadata]

perform_file_metadata_action(action, file_metadata=None, file_id=None)[source]

Perform a database action (CRUD) on file metadata.

Return type:

FileMetadata

synchronize_with_storage(storage_directory)[source]

Synchronize the files metadata database with the actual files in the storage directory.

This method ensures that the database entries accurately reflect the files present in the storage directory. It adds metadata for new files, updates metadata for existing files, and removes metadata for deleted files.

Parameters:

storage_directory (Path) – The path to the storage directory to synchronize with

Return type:

None