mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 13:41:23 +00:00
fix(backup): remote disk backups never appear in backup listing
Three bugs prevented backups stored on remote disks (Dropbox, S3, etc.) from ever appearing in the Settings > Backup listing: 1. Typo in BackupSetting.vue: `filed_disk_id` was sent to the API instead of `file_disk_id`, so the backend never received the selected disk ID and always fell back to the local filesystem. 2. Wrong default disk selection in loadDisksData(): `set_as_default == 0` selected the first disk that is NOT default (local_public), instead of the disk that IS default. Changed to `set_as_default == 1` with a fallback to the first disk. 3. BackupsController::index() did not call setConfig() on the FileDisk before querying backups, so even when the correct file_disk_id arrived it still read from the default local filesystem. Added the same disk bootstrap logic already present in CreateBackupJob and destroy(). Made-with: Cursor
This commit is contained in:
@@ -27,6 +27,16 @@ class BackupsController extends ApiController
|
|||||||
$configuredBackupDisks = config('backup.backup.destination.disks');
|
$configuredBackupDisks = config('backup.backup.destination.disks');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if ($request->file_disk_id) {
|
||||||
|
$fileDisk = \App\Models\FileDisk::find($request->file_disk_id);
|
||||||
|
if ($fileDisk) {
|
||||||
|
$fileDisk->setConfig();
|
||||||
|
$prefix = env('DYNAMIC_DISK_PREFIX', 'temp_');
|
||||||
|
config(['backup.backup.destination.disks' => [$prefix.$fileDisk->driver]]);
|
||||||
|
$configuredBackupDisks = config('backup.backup.destination.disks');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$backupDestination = BackupDestination::create(config('filesystems.default'), config('backup.backup.name'));
|
$backupDestination = BackupDestination::create(config('filesystems.default'), config('backup.backup.name'));
|
||||||
|
|
||||||
$backups = Cache::remember("backups-{$request->file_disk_id}", now()->addSeconds(4), function () use ($backupDestination) {
|
$backups = Cache::remember("backups-{$request->file_disk_id}", now()->addSeconds(4), function () use ($backupDestination) {
|
||||||
|
|||||||
@@ -167,14 +167,14 @@ async function loadDisksData() {
|
|||||||
let res = await diskStore.fetchDisks({ limit: 'all' })
|
let res = await diskStore.fetchDisks({ limit: 'all' })
|
||||||
if (res.data.error) {
|
if (res.data.error) {
|
||||||
}
|
}
|
||||||
filters.selected_disk = res.data.data.find((disk) => disk.set_as_default == 0)
|
filters.selected_disk = res.data.data.find((disk) => disk.set_as_default == 1) ?? res.data.data[0]
|
||||||
isFetchingInitialData.value = false
|
isFetchingInitialData.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchBackupsData({ page, filter, sort }) {
|
async function fetchBackupsData({ page, filter, sort }) {
|
||||||
let data = {
|
let data = {
|
||||||
disk: filters.selected_disk.driver,
|
disk: filters.selected_disk.driver,
|
||||||
filed_disk_id: filters.selected_disk.id,
|
file_disk_id: filters.selected_disk.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
isFetchingInitialData.value = true
|
isFetchingInitialData.value = true
|
||||||
|
|||||||
Reference in New Issue
Block a user