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() api.shutdown()
}, },
}) })
const { pid } = childProcess const { pid } = childProcess
assertTruthy(pid, `Expected PID here but got ${pid}`) 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 invocation = await client.createInvocation(instance, pid)
const tm = createTimerManager({}) const tm = createTimerManager({})
const api: InstanceApi = (() => { const api: InstanceApi = (() => {

View File

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

View File

@ -136,13 +136,13 @@ open https://pockethost.io
**next** **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] fix: more helpful error message when backup fails for nonexistent instance
- [x] chore: move version number to base package.json - [x] chore: move version number to base package.json
- [x] refactor: logging and async helpers - [x] refactor: logging and async helpers
- [x] chore: restore auto-cancellation - [x] chore: restore auto-cancellation
- [x] chore: rebuild with go 1.19.3 and include in bin name - [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** **0.5.2**