Documentation
¶
Overview ¶
Package backup contains the shared upload preparation for backup restores.
Index ¶
Constants ¶
const (
MaxArchiveSize int64 = 4 << 30 // 4 GiB
)
Variables ¶
This section is empty.
Functions ¶
func CleanupStagedUploads ¶ added in v0.1.20
CleanupStagedUploads reclaims staging files a process that died mid-upload left in ./data. SaveUploadedBackup removes its temporary file on every error path, and ValidateArchive removes its temporary database copy the same way, so a file that survives belongs to a process that was killed in between -- up to MaxArchiveSize each for an upload, or one database for a content check. Nothing else reclaims them: the startup restore only clears ./data when a backup.zip is actually waiting, so an abandoned staging file would otherwise sit on the disk indefinitely.
Only the exact names os.CreateTemp produces from the patterns in this package are eligible, and only regular files, so an operator's own file in ./data is never touched. The restore lock is taken for the duration: if a restore is already staging a file, that operation owns its cleanup.
func SaveUploadedBackup ¶
SaveUploadedBackup validates a Komari backup and stages it for restoration during the next process startup.
func ValidateArchive ¶
ValidateArchive checks the backup marker and bounds archive expansion before the startup restore path extracts it into data/, and rejects an archive whose komari.db is missing, empty, truncated or corrupt.
The content check is what stands between an unusable upload and a destructive restore: the startup path clears ./data and only then unzips this archive, so an archive that passes here but holds a broken database would leave the panel with an empty data directory and the install wizard.
Types ¶
type RestoreLock ¶
type RestoreLock struct {
// contains filtered or unexported fields
}
RestoreLock serializes staging a backup until the caller releases it. A successful restore must hold this lock until the process restarts so a second request cannot replace backup.zip in the meantime.
func AcquireRestoreLock ¶
func AcquireRestoreLock() (*RestoreLock, error)
func (*RestoreLock) Release ¶
func (l *RestoreLock) Release()
func (*RestoreLock) SaveUploadedBackup ¶
func (l *RestoreLock) SaveUploadedBackup(file io.Reader, filename string) error
SaveUploadedBackup stages a backup while the caller holds the restore lock.