|
game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
|
Service for managing Wine prefix snapshots. More...
#include <prefix_snapshot_service.h>
Classes | |
| struct | Impl |
Public Types | |
| using | ProgressCallback = std::function<void(const SnapshotProgress&)> |
Public Member Functions | |
| PrefixSnapshotService () | |
| ~PrefixSnapshotService () | |
| void | cancelOperation () |
| Cancel ongoing operation. | |
| int | cleanupOldAutoSnapshots (int maxAgeDays=30) |
| Clean up auto-snapshots older than specified days. | |
| int | cleanupOldSnapshots (int keepCount=5) |
| Clean up old snapshots, keeping newest N per prefix. | |
| PrefixDiff | compareSnapshots (const std::string &snapshotId1, const std::string &snapshotId2) const |
| Compare two snapshots. | |
| PrefixDiff | compareWithCurrent (const std::filesystem::path &prefixPath, const std::string &snapshotId) const |
| Compare current prefix state with a snapshot. | |
| std::optional< PrefixSnapshot > | createAutoSnapshot (const std::filesystem::path &prefixPath, const std::string &gameId, const std::string &gameName, const std::string &reason) |
| Create automatic snapshot for a game. | |
| std::optional< PrefixSnapshot > | createIncrementalSnapshot (const std::filesystem::path &prefixPath, const std::string &parentSnapshotId, const std::string &name, const ProgressCallback &progressCallback=nullptr) |
| Create an incremental snapshot (only changes since parent). | |
| std::optional< PrefixSnapshot > | createSnapshot (const std::filesystem::path &prefixPath, const std::string &name, const std::string &description="", const ProgressCallback &progressCallback=nullptr) |
| Create a full snapshot of a prefix. | |
| std::future< std::optional< PrefixSnapshot > > | createSnapshotAsync (const std::filesystem::path &prefixPath, const std::string &name, const std::string &description="", const ProgressCallback &progressCallback=nullptr) |
| Create a snapshot asynchronously. | |
| bool | deleteSnapshot (const std::string &snapshotId) |
| Delete a snapshot. | |
| int | deleteSnapshotsForPrefix (const std::filesystem::path &prefixPath) |
| Delete all snapshots for a prefix. | |
| bool | exportSnapshot (const std::string &snapshotId, const std::filesystem::path &outputPath, const ProgressCallback &progressCallback=nullptr) |
| Export a snapshot to a portable archive. | |
| std::vector< PrefixSnapshot > | getAllSnapshots () const |
| Get all snapshots. | |
| std::optional< PrefixSnapshot > | getSnapshot (const std::string &snapshotId) const |
| Get a specific snapshot by ID. | |
| std::filesystem::path | getSnapshotDirectory () const |
| Get current snapshot directory. | |
| std::vector< PrefixSnapshot > | getSnapshotsForGame (const std::string &gameId) const |
| Get snapshots for a specific game. | |
| std::vector< PrefixSnapshot > | getSnapshotsForPrefix (const std::filesystem::path &prefixPath) const |
| Get snapshots for a specific prefix. | |
| int64_t | getTotalSnapshotSize () const |
| Get total space used by all snapshots. | |
| std::optional< PrefixSnapshot > | importSnapshot (const std::filesystem::path &archivePath, const ProgressCallback &progressCallback=nullptr) |
| Import a snapshot from archive. | |
| std::vector< std::filesystem::path > | listSnapshotFiles (const std::string &snapshotId) const |
| List files in a snapshot. | |
| bool | renameSnapshot (const std::string &snapshotId, const std::string &newName) |
| Rename a snapshot. | |
| bool | restoreFiles (const std::string &snapshotId, const std::vector< std::filesystem::path > &files) |
| Restore specific files from a snapshot. | |
| bool | restoreSnapshot (const std::string &snapshotId, const ProgressCallback &progressCallback=nullptr) |
| Restore a prefix from snapshot. | |
| std::future< bool > | restoreSnapshotAsync (const std::string &snapshotId, const ProgressCallback &progressCallback=nullptr) |
| Restore a snapshot asynchronously. | |
| void | setCompressionEnabled (bool enabled) |
| Enable/disable compression for snapshots. | |
| void | setMaxStorageSize (int64_t maxBytes) |
| Set maximum total snapshot storage size. | |
| void | setSnapshotDirectory (const std::filesystem::path &path) |
| Set snapshot storage directory. | |
| bool | updateDescription (const std::string &snapshotId, const std::string &description) |
| Update snapshot description. | |
Service for managing Wine prefix snapshots.
Provides methods for creating, restoring, and managing prefix snapshots for Wine and Proton game prefixes.
Definition at line 142 of file prefix_snapshot_service.h.
| using PrefixSnapshotService::ProgressCallback = std::function<void(const SnapshotProgress&)> |
Definition at line 145 of file prefix_snapshot_service.h.
| PrefixSnapshotService::PrefixSnapshotService | ( | ) |
Definition at line 110 of file prefix_snapshot_service.cpp.
| PrefixSnapshotService::~PrefixSnapshotService | ( | ) |
Definition at line 128 of file prefix_snapshot_service.cpp.
References cancelOperation().
| void PrefixSnapshotService::cancelOperation | ( | ) |
Cancel ongoing operation.
Definition at line 1432 of file prefix_snapshot_service.cpp.
Referenced by ~PrefixSnapshotService().
| int PrefixSnapshotService::cleanupOldAutoSnapshots | ( | int | maxAgeDays = 30 | ) |
Clean up auto-snapshots older than specified days.
| maxAgeDays | Maximum age in days |
Definition at line 1159 of file prefix_snapshot_service.cpp.
References PrefixSnapshot::created, deleteSnapshot(), PrefixSnapshot::gameId, getAllSnapshots(), PrefixSnapshot::id, and Logger::info().
| int PrefixSnapshotService::cleanupOldSnapshots | ( | int | keepCount = 5 | ) |
Clean up old snapshots, keeping newest N per prefix.
| keepCount | Number of snapshots to keep per prefix |
Definition at line 1126 of file prefix_snapshot_service.cpp.
References Logger::info(), and PrefixSnapshot::prefixPath.
| PrefixDiff PrefixSnapshotService::compareSnapshots | ( | const std::string & | snapshotId1, |
| const std::string & | snapshotId2 ) const |
Compare two snapshots.
| snapshotId1 | First snapshot ID |
| snapshotId2 | Second snapshot ID |
Definition at line 942 of file prefix_snapshot_service.cpp.
References PrefixDiff::addedFiles, Logger::error(), getSnapshot(), PrefixDiff::modifiedFiles, and PrefixDiff::removedFiles.
| PrefixDiff PrefixSnapshotService::compareWithCurrent | ( | const std::filesystem::path & | prefixPath, |
| const std::string & | snapshotId ) const |
Compare current prefix state with a snapshot.
| prefixPath | Current prefix path |
| snapshotId | Snapshot to compare against |
Definition at line 1014 of file prefix_snapshot_service.cpp.
References PrefixDiff::addedFiles, Logger::error(), getSnapshot(), PrefixDiff::modifiedFiles, PrefixDiff::removedFiles, and PrefixSnapshot::snapshotPath.
| std::optional< PrefixSnapshot > PrefixSnapshotService::createAutoSnapshot | ( | const std::filesystem::path & | prefixPath, |
| const std::string & | gameId, | ||
| const std::string & | gameName, | ||
| const std::string & | reason ) |
Create automatic snapshot for a game.
| prefixPath | Path to Wine prefix |
| gameId | Game ID |
| gameName | Game name |
| reason | Reason for snapshot (e.g., "pre-launch", "post-install") |
Definition at line 599 of file prefix_snapshot_service.cpp.
References createSnapshot().
| std::optional< PrefixSnapshot > PrefixSnapshotService::createIncrementalSnapshot | ( | const std::filesystem::path & | prefixPath, |
| const std::string & | parentSnapshotId, | ||
| const std::string & | name, | ||
| const ProgressCallback & | progressCallback = nullptr ) |
Create an incremental snapshot (only changes since parent).
| prefixPath | Path to Wine prefix |
| parentSnapshotId | ID of parent snapshot |
| name | Snapshot name |
| progressCallback | Progress updates |
Definition at line 567 of file prefix_snapshot_service.cpp.
References createSnapshot(), Logger::error(), and getSnapshot().
| std::optional< PrefixSnapshot > PrefixSnapshotService::createSnapshot | ( | const std::filesystem::path & | prefixPath, |
| const std::string & | name, | ||
| const std::string & | description = "", | ||
| const ProgressCallback & | progressCallback = nullptr ) |
Create a full snapshot of a prefix.
| prefixPath | Path to Wine prefix |
| name | Snapshot name |
| description | Optional description |
| progressCallback | Progress updates |
Definition at line 456 of file prefix_snapshot_service.cpp.
References PrefixSnapshot::architecture, SnapshotProgress::Cancelled, SnapshotProgress::Completed, PrefixSnapshot::created, PrefixSnapshot::description, Logger::error(), SnapshotProgress::errorMessage, SnapshotProgress::Failed, PrefixSnapshot::fileCount, PrefixSnapshot::getFormattedSize(), PrefixSnapshot::id, Logger::info(), PrefixSnapshot::name, SnapshotProgress::percentComplete, PrefixSnapshot::prefixPath, SnapshotProgress::Scanning, PrefixSnapshot::sizeBytes, PrefixSnapshot::snapshotPath, SnapshotProgress::state, and PrefixSnapshot::wineVersion.
Referenced by createAutoSnapshot(), createIncrementalSnapshot(), createSnapshotAsync(), and restoreSnapshot().
| std::future< std::optional< PrefixSnapshot > > PrefixSnapshotService::createSnapshotAsync | ( | const std::filesystem::path & | prefixPath, |
| const std::string & | name, | ||
| const std::string & | description = "", | ||
| const ProgressCallback & | progressCallback = nullptr ) |
Create a snapshot asynchronously.
Definition at line 559 of file prefix_snapshot_service.cpp.
References createSnapshot().
| bool PrefixSnapshotService::deleteSnapshot | ( | const std::string & | snapshotId | ) |
Delete a snapshot.
| snapshotId | Snapshot ID to delete |
Definition at line 874 of file prefix_snapshot_service.cpp.
Referenced by cleanupOldAutoSnapshots().
| int PrefixSnapshotService::deleteSnapshotsForPrefix | ( | const std::filesystem::path & | prefixPath | ) |
Delete all snapshots for a prefix.
| prefixPath | Prefix path |
Definition at line 880 of file prefix_snapshot_service.cpp.
References PrefixSnapshot::prefixPath.
| bool PrefixSnapshotService::exportSnapshot | ( | const std::string & | snapshotId, |
| const std::filesystem::path & | outputPath, | ||
| const ProgressCallback & | progressCallback = nullptr ) |
Export a snapshot to a portable archive.
| snapshotId | Snapshot ID |
| outputPath | Output archive path |
| progressCallback | Progress updates |
Definition at line 1188 of file prefix_snapshot_service.cpp.
References Logger::error(), ShellUtils::escapeArg(), getSnapshot(), Logger::info(), and PrefixSnapshot::snapshotPath.
| std::vector< PrefixSnapshot > PrefixSnapshotService::getAllSnapshots | ( | ) | const |
Get all snapshots.
Definition at line 777 of file prefix_snapshot_service.cpp.
Referenced by cleanupOldAutoSnapshots().
| std::optional< PrefixSnapshot > PrefixSnapshotService::getSnapshot | ( | const std::string & | snapshotId | ) | const |
Get a specific snapshot by ID.
| snapshotId | Snapshot ID |
Definition at line 837 of file prefix_snapshot_service.cpp.
Referenced by compareSnapshots(), compareWithCurrent(), createIncrementalSnapshot(), exportSnapshot(), listSnapshotFiles(), restoreFiles(), and restoreSnapshot().
| fs::path PrefixSnapshotService::getSnapshotDirectory | ( | ) | const |
Get current snapshot directory.
Definition at line 1414 of file prefix_snapshot_service.cpp.
| std::vector< PrefixSnapshot > PrefixSnapshotService::getSnapshotsForGame | ( | const std::string & | gameId | ) | const |
Get snapshots for a specific game.
| gameId | Game ID |
Definition at line 817 of file prefix_snapshot_service.cpp.
References PrefixSnapshot::gameId.
| std::vector< PrefixSnapshot > PrefixSnapshotService::getSnapshotsForPrefix | ( | const std::filesystem::path & | prefixPath | ) | const |
Get snapshots for a specific prefix.
| prefixPath | Prefix path |
Definition at line 797 of file prefix_snapshot_service.cpp.
References PrefixSnapshot::prefixPath.
| int64_t PrefixSnapshotService::getTotalSnapshotSize | ( | ) | const |
Get total space used by all snapshots.
Definition at line 1114 of file prefix_snapshot_service.cpp.
References PrefixSnapshot::sizeBytes.
| std::optional< PrefixSnapshot > PrefixSnapshotService::importSnapshot | ( | const std::filesystem::path & | archivePath, |
| const ProgressCallback & | progressCallback = nullptr ) |
Import a snapshot from archive.
| archivePath | Archive file path |
| progressCallback | Progress updates |
Definition at line 1215 of file prefix_snapshot_service.cpp.
References PipeHandle::close(), PrefixSnapshot::created, Logger::error(), ShellUtils::escapeArg(), PrefixSnapshot::fileCount, PipeHandle::get(), PrefixSnapshot::id, Logger::info(), PrefixSnapshot::name, PrefixSnapshot::sizeBytes, PrefixSnapshot::snapshotPath, and Logger::warn().
| std::vector< fs::path > PrefixSnapshotService::listSnapshotFiles | ( | const std::string & | snapshotId | ) | const |
List files in a snapshot.
| snapshotId | Snapshot ID |
Definition at line 1084 of file prefix_snapshot_service.cpp.
References Logger::error(), getSnapshot(), and PrefixSnapshot::snapshotPath.
| bool PrefixSnapshotService::renameSnapshot | ( | const std::string & | snapshotId, |
| const std::string & | newName ) |
Rename a snapshot.
| snapshotId | Snapshot ID |
| newName | New name |
Definition at line 906 of file prefix_snapshot_service.cpp.
| bool PrefixSnapshotService::restoreFiles | ( | const std::string & | snapshotId, |
| const std::vector< std::filesystem::path > & | files ) |
Restore specific files from a snapshot.
| snapshotId | Snapshot ID |
| files | List of files to restore (relative paths) |
Definition at line 727 of file prefix_snapshot_service.cpp.
References Logger::error(), getSnapshot(), and Logger::warn().
| bool PrefixSnapshotService::restoreSnapshot | ( | const std::string & | snapshotId, |
| const ProgressCallback & | progressCallback = nullptr ) |
Restore a prefix from snapshot.
| snapshotId | Snapshot ID to restore |
| progressCallback | Progress updates |
Creates a backup of current state before restoring.
Definition at line 629 of file prefix_snapshot_service.cpp.
References SnapshotProgress::Completed, createSnapshot(), Logger::error(), SnapshotProgress::errorMessage, SnapshotProgress::Failed, getSnapshot(), Logger::info(), SnapshotProgress::percentComplete, SnapshotProgress::state, and Logger::warn().
Referenced by restoreSnapshotAsync().
| std::future< bool > PrefixSnapshotService::restoreSnapshotAsync | ( | const std::string & | snapshotId, |
| const ProgressCallback & | progressCallback = nullptr ) |
Restore a snapshot asynchronously.
Definition at line 720 of file prefix_snapshot_service.cpp.
References restoreSnapshot().
| void PrefixSnapshotService::setCompressionEnabled | ( | bool | enabled | ) |
Enable/disable compression for snapshots.
| enabled | Whether to compress |
Definition at line 1420 of file prefix_snapshot_service.cpp.
| void PrefixSnapshotService::setMaxStorageSize | ( | int64_t | maxBytes | ) |
Set maximum total snapshot storage size.
| maxBytes | Maximum size in bytes (0 = unlimited) |
Definition at line 1426 of file prefix_snapshot_service.cpp.
| void PrefixSnapshotService::setSnapshotDirectory | ( | const std::filesystem::path & | path | ) |
Set snapshot storage directory.
| path | Directory path |
Definition at line 1405 of file prefix_snapshot_service.cpp.
| bool PrefixSnapshotService::updateDescription | ( | const std::string & | snapshotId, |
| const std::string & | description ) |
Update snapshot description.
| snapshotId | Snapshot ID |
| description | New description |
Definition at line 922 of file prefix_snapshot_service.cpp.