Skip to content

Commit

Permalink
fix: display error on restore when no backup files exist
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Sep 9, 2020
1 parent 7a99f48 commit 3bd4caa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/sync-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ module.exports = class SyncSettings {
return
}

if (!backupData.settings && !backupData.packages && !backupData.files) {
notify.error('Sync-Settings: No backup files found.')
return
}

if (atom.config.get('sync-settings.removeUnfamiliarFiles')) {
const localData = await this.getLocalData()
if (!localData) {
Expand Down Expand Up @@ -322,7 +327,7 @@ module.exports = class SyncSettings {
if (link) {
shell.openExternal(link)
} else {
notify.warn('Sync-Settings: No link available for the backup location.')
notify.warning('Sync-Settings: No link available for the backup location.')
}
}

Expand Down
10 changes: 10 additions & 0 deletions spec/sync-settings-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,14 @@ describe('syncSettings', () => {
expect(atom.config.get('some-dummy')).toBeTruthy()
})

it('displays an error when no backup files exist', async () => {
atom.notifications.clear()
await syncSettings.restore()

expect(atom.notifications.getNotifications().length).toEqual(1)
expect(atom.notifications.getNotifications()[0].getType()).toBe('error')
})

it('restores keys with dots', async () => {
atom.config.set('sync-settings.syncSettings', true)
atom.config.set('some\\.key', ['one', 'two'])
Expand Down Expand Up @@ -955,6 +963,8 @@ describe('syncSettings', () => {
})

it('updates last time on restore', async () => {
await syncSettings.backup()
atom.config.unset('sync-settings.hiddenSettings._lastBackupTime')
await syncSettings.restore()

expect(atom.config.get('sync-settings.hiddenSettings._lastBackupTime')).toBeDefined()
Expand Down

0 comments on commit 3bd4caa

Please sign in to comment.