diff --git a/README.md b/README.md index 1bfd795..b1db07d 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,10 @@ A Signal Desktop–style SMS client for [voip.ms](https://voip.ms). It keeps you | What | Where | Backed up? | |---|---|---| -| Message database | `~/Documents/voipms-desktop-data/messages.db` | ✅ Déjà Dup covers `~/Documents` | -| Daily snapshots, last 7 kept | `~/Documents/voipms-desktop-data/snapshots/` | ✅ | -| Settings | `~/Documents/voipms-desktop-data/settings.json` | ✅ | -| MMS photos and attachments (cached on arrival) | `~/Documents/voipms-desktop-data/media/` | ✅ | +| Message database | `~/Documents/bubble-data/messages.db` | ✅ Déjà Dup covers `~/Documents` | +| Daily snapshots, last 7 kept | `~/Documents/bubble-data/snapshots/` | ✅ | +| Settings | `~/Documents/bubble-data/settings.json` | ✅ | +| MMS photos and attachments (cached on arrival) | `~/Documents/bubble-data/media/` | ✅ | | API password | GNOME Keyring (via Electron `safeStorage`) → `~/.config/voipms-desktop/credentials.bin` | ❌ on purpose; you re-enter it after a restore | | Contact photo cache | `~/.config/voipms-desktop/photo-cache/` | ❌ not needed | | Rabbit relay address, token and key | GNOME Keyring → `~/.config/voip.ms Messages/relay.bin` | ❌ on purpose; reconnect and Sync to Rabbit after a restore | diff --git a/package.json b/package.json index 6b6ede2..20cac4d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "voipms-desktop", "productName": "bubble", - "version": "0.8.8", + "version": "0.9.0", "description": "Signal-style desktop SMS client for voip.ms", "author": "trav ", "private": true, diff --git a/resources/android/VoipMessages.apk b/resources/android/VoipMessages.apk index 09ef9de..6dd51bc 100644 Binary files a/resources/android/VoipMessages.apk and b/resources/android/VoipMessages.apk differ diff --git a/src/main/index.ts b/src/main/index.ts index f59131f..f8e016b 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -16,7 +16,7 @@ import { MediaStore } from './media' import { exportHtml, exportText, inRange, rangeLabel } from './export' import { extFor, guessMime } from '@shared/mime' import { clearCredentials, loadCredentials, saveCredentials } from './secrets' -import { getDataDir, loadSettings, saveSettings, setDataDir } from './settings' +import { getDataDir, loadSettings, moveToBubbleData, saveSettings, setDataDir } from './settings' import { SyncEngine } from './sync' import { loadZoom, saveZoom } from './uistate' import { sendWithRetry } from './send' @@ -798,6 +798,7 @@ app.on('second-instance', () => { }) app.whenReady().then(async () => { + moveToBubbleData() settings = loadSettings() db = new MessageDb(path.join(getDataDir(), 'messages.db')) if (SANDBOX) seedDemo(db) diff --git a/src/main/settings.ts b/src/main/settings.ts index b1bf5fa..288bb83 100644 --- a/src/main/settings.ts +++ b/src/main/settings.ts @@ -1,6 +1,6 @@ // Where the data lives + non-secret preferences. // -// The message database defaults to ~/Documents/voipms-desktop-data so Déjà Dup +// The message database defaults to ~/Documents/bubble-data so Déjà Dup // backs it up (it excludes ~/.config, ~/.local and ~/.cache). A small pointer // file in Electron's userData remembers a custom location if one is chosen. import { app } from 'electron' @@ -19,7 +19,47 @@ const DEFAULTS: Settings = { const pointerFile = (): string => path.join(app.getPath('userData'), 'data-location.json') export function defaultDataDir(): string { - return path.join(app.getPath('documents'), 'voipms-desktop-data') + return path.join(app.getPath('documents'), 'bubble-data') +} + +// Where it lived before the app was called bubble. +const OLD_NAME = 'voipms-desktop-data' + +// Once, before anything opens the database: copy ~/Documents/voipms-desktop-data +// to ~/Documents/bubble-data (via a .partial folder, renamed only when the +// copy is whole) and use that. The old folder stays as a backup, with a note +// saying so, for its owner to delete. Only the default place moves: a folder +// chosen in Settings stays where it is. If the copy fails, carry on in the old +// folder rather than starting an empty history. +export function moveToBubbleData(): void { + if (process.env['VOIPMS_DATA_DIR']) return + const old = path.join(app.getPath('documents'), OLD_NAME) + const dest = defaultDataDir() + let pointed: string | undefined + try { + pointed = (JSON.parse(fs.readFileSync(pointerFile(), 'utf8')) as { dataDir?: string }).dataDir + } catch { + /* no pointer: the default place */ + } + if (pointed && path.resolve(pointed) !== path.resolve(old)) return + if (!fs.existsSync(path.join(old, 'messages.db')) || fs.existsSync(dest)) return + const partial = `${dest}.partial` + try { + fs.rmSync(partial, { recursive: true, force: true }) // a copy cut short last time + console.log(`[data] copying ${old} to ${dest}`) + fs.cpSync(old, partial, { recursive: true, preserveTimestamps: true, errorOnExist: true }) + fs.renameSync(partial, dest) + if (pointed) setDataDir(dest) + fs.writeFileSync( + path.join(old, 'MOVED TO bubble-data.txt'), + `bubble copied this folder to ${dest} on ${new Date().toString()} and uses that one now.\n` + + `This is the backup from before the move: once bubble looks right, it can be deleted.\n` + ) + } catch (e) { + console.error('[data] copy to bubble-data failed; staying in the old folder:', e) + fs.rmSync(partial, { recursive: true, force: true }) + setDataDir(old) + } } export function getDataDir(): string {