ソースを参照

Add ability to list all backups

Rich Infante 7 年 前
コミット
d2d2f490c6
4 ファイル変更14 行追加13 行削除
  1. 1 1
      package.json
  2. 1 1
      tools/index.js
  3. 12 10
      tools/reports/list.js
  4. 0 1
      tools/util/iphone_backup.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "ibackuptool",
-  "version": "2.0.4",
+  "version": "2.0.5",
   "description": "Read Messages and info from iOS Backups",
   "main": "tools/index.js",
   "scripts": {

+ 1 - 1
tools/index.js

@@ -22,7 +22,7 @@ var reportTypes = {
 }
 
 program
-    .version('2.0.4')
+    .version('2.0.5')
     .option('-l, --list', 'List Backups')
     .option(`-b, --backup <backup>`, 'Backup ID')
     .option('-r, --report <report_type>', 'Select a report type. see below for a full list.')

+ 12 - 10
tools/reports/list.js

@@ -9,7 +9,7 @@ module.exports.description = 'List of all backups. alias for -l'
 
 module.exports.func = function (program, base) {
   var items = fs.readdirSync(base, { encoding: 'utf8' })
-    .filter(el => (el.length === 40))
+    .filter(el => (el !== '.DS_Store'))
     .map(file => iPhoneBackup.fromID(file, base))
 
     // Possibly dump output
@@ -19,6 +19,7 @@ module.exports.func = function (program, base) {
   }
 
   items = items.map(el => {
+    if (!el.manifest || !el.status) { return null }
     return {
       encrypted: el.manifest ? el.manifest.IsEncrypted
                                     ? chalk.green('encrypted')
@@ -32,15 +33,16 @@ module.exports.func = function (program, base) {
       date: el.status ? new Date(el.status.Date).toLocaleString() : ''
     }
   })
-    .map(el => [
-      chalk.gray(el.device_id),
-      el.encrypted,
-      el.date,
-      el.device_name,
-      el.serial,
-      el.iOSVersion,
-      el.backupVersion
-    ])
+  .filter(el => el != null)
+  .map(el => [
+    chalk.gray(el.device_id),
+    el.encrypted,
+    el.date,
+    el.device_name,
+    el.serial,
+    el.iOSVersion,
+    el.backupVersion
+  ])
 
   items = [
     ['UDID', 'Encryption', 'Date', 'Device Name', 'Serial #', 'iOS Version', 'Backup Version'],

+ 0 - 1
tools/util/iphone_backup.js

@@ -429,7 +429,6 @@ module.exports.availableBackups = function () {
   const base = path.join(process.env.HOME, '/Library/Application Support/MobileSync/Backup/')
   return new Promise((resolve, reject) => {
     resolve(fs.readdirSync(base, { encoding: 'utf8' })
-      .filter(el => el.length == 40)
       .map(file => iPhoneBackup.fromID(file)))
   })
 }