fix: disallow backups if data dir doesn't exist

This commit is contained in:
Ben Allfree 2022-11-21 02:19:42 -08:00
parent 4e65a7b948
commit c798f067c6
3 changed files with 49 additions and 39 deletions

View File

@ -119,9 +119,14 @@ export const createInstanceService = async (config: InstanceServiceConfig) => {
api.shutdown()
},
})
const { pid } = childProcess
assertTruthy(pid, `Expected PID here but got ${pid}`)
if (!instance.isBackupAllowed) {
await client.updateInstance(instance.id, { isBackupAllowed: true })
}
const invocation = await client.createInvocation(instance, pid)
const tm = createTimerManager({})
const api: InstanceApi = (() => {

View File

@ -58,44 +58,49 @@
<div class="py-4">
<h2>Backup</h2>
<div class="text-center py-5">
<button class="btn btn-light" on:click={() => startBackup()} disabled={isBackingUp}>
<i class="bi bi-safe" /> Backup Now
</button>
</div>
{#if instance.isBackupAllowed}
<div class="text-center py-5">
<button class="btn btn-light" on:click={() => startBackup()} disabled={isBackingUp}>
<i class="bi bi-safe" /> Backup Now
</button>
</div>
<div>
{#each $backups as { id, bytes, updated, platform, version, status, message, progress }}
<div>
{#if status === BackupStatus.FinishedSuccess}
<div class="text-success">
{platform}:{version} ({prettyBytes(bytes)}) - Finished {new Date(updated)}
</div>
{/if}
{#if status === BackupStatus.FinishedError}
<div class="text-danger">
{platform}:{version} - Finished {new Date(updated)}
<AlertBar icon="bi bi-exclamation-triangle-fill" text={message} />
</div>
{/if}
{#if status !== BackupStatus.FinishedError && status !== BackupStatus.FinishedSuccess}
<div class="text-warning">
{platform}:{version}
{status}
{#each Object.entries(progress || {}) as [src, pct]}
<div class="badge bg-secondary" style="margin-right: 3px">
{src}
<code>
{Math.ceil(pct * 100)}%
</code>
</div>
{/each}
Started {formatDistanceToNow(Date.parse(updated))} ago
</div>
{/if}
</div>
{/each}
</div>
<div>
{#each $backups as { id, bytes, updated, platform, version, status, message, progress }}
<div>
{#if status === BackupStatus.FinishedSuccess}
<div class="text-success">
{platform}:{version} ({prettyBytes(bytes)}) - Finished {new Date(updated)}
</div>
{/if}
{#if status === BackupStatus.FinishedError}
<div class="text-danger">
{platform}:{version} - Finished {new Date(updated)}
<AlertBar icon="bi bi-exclamation-triangle-fill" text={message} />
</div>
{/if}
{#if status !== BackupStatus.FinishedError && status !== BackupStatus.FinishedSuccess}
<div class="text-warning">
{platform}:{version}
{status}
{#each Object.entries(progress || {}) as [src, pct]}
<div class="badge bg-secondary" style="margin-right: 3px">
{src}
<code>
{Math.ceil(pct * 100)}%
</code>
</div>
{/each}
Started {formatDistanceToNow(Date.parse(updated))} ago
</div>
{/if}
</div>
{/each}
</div>
{/if}
{#if !instance.isBackupAllowed}
You must access this instance at least once before backups can be made.
{/if}
</div>
<style lang="scss">

View File

@ -136,13 +136,13 @@ open https://pockethost.io
**next**
- [x] fix: incorrect instance information displaying on dashboard details
- [x] fix: incorrect instance information displaying on dashboard details in some cases
- [x] fix: more helpful error message when backup fails for nonexistent instance
- [x] chore: move version number to base package.json
- [x] refactor: logging and async helpers
- [x] chore: restore auto-cancellation
- [x] chore: rebuild with go 1.19.3 and include in bin name
- [ ] fix: Disallow backups if data dir doesn't exist
- [x] fix: Disallow backups if data dir doesn't exist
**0.5.2**