Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle files with missing domain or path #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions tools/reports/backup/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = {
path: el => el.filename,
size: el => el.filelen || 0,
mtime: el => el.mtime || 0,
mode: el => new Mode(el).toString()
mode: el => el.mode && new Mode(el).toString()
}
}

Expand All @@ -44,15 +44,20 @@ function getSqliteFileManifest (backup) {
backup.openDatabase('Manifest.db', true)
.then(db => {
db.all('SELECT fileID, domain, relativePath as filename, file from FILES', async function (err, rows) {
if (err) reject(err)
if (err) {
reject(err)
return
}

// Extract binary plist metadata
for (var row of rows) {
let data = plist.parseBuffer(row.file)
let metadata = data['$objects'][1];
row.filelen = metadata.Size
row.mode = metadata.Mode
row.mtime = row.atime = metadata.LastModified
if (row.file) {
let data = plist.parseBuffer(row.file)
let metadata = data['$objects'][1];
row.filelen = metadata.Size
row.mode = metadata.Mode
row.mtime = row.atime = metadata.LastModified
}
}

resolve(rows)
Expand Down Expand Up @@ -131,6 +136,11 @@ function isIncludedBySingleFilterCheck (filter, x) {
function extractFiles (backup, destination, filter, items) {
for (var item of items) {
try {
if (!item.domain || !item.filename) {
log.warning(`skipping fileID ${item.fileID} without domain or path`)
continue
}

var domainPath = item.domain
if (domainPath.match(/^AppDomain.*-/)) {
// Extract sub-domain from app domain
Expand Down