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

Delete local cloud files #258

Merged
merged 8 commits into from
Jan 11, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/agent/actions/geofencing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function sync(geofences) {

if (len === 0) {
storage.clear_geo(function(err) {
if (err) logger.err("Error deleting geofences from local database")
if (err) logger.error("Error deleting geofences from local database")
watcher.stop(done);
})
} else {
Expand Down
31 changes: 31 additions & 0 deletions lib/agent/actions/wipe/linux.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
exports.stopCloudProcess = function(folders, cb) {
folders.forEach(function(value, index) {
exec('pkill -9 ' + folders[index].toLowerCase(), cb)
})
}

exports.getDropboxOldDirs = function(home, cb) {
var paths = [];
exec('find ' + home + ' -maxdepth 2 -name "Dropbox (*"', function(err, stdout) {
if (err || !stdout) return cb(null, paths)

stdout = stdout.split("\n").slice(0, -1);

stdout.forEach(function(entry, index) {
paths[index] = entry.split('/').pop()
})
// Delete repeated values
paths = paths.filter(function(elem, index, self) {
return index == self.indexOf(elem);
})

cb(null, paths);
})
}

exports.paths = {
keychains: ['.gnome2/keyrings', '.ssh'],
documents: ['Documents', 'Downloads', 'Desktop', 'Pictures', 'Videos'],
Expand All @@ -6,5 +31,11 @@ exports.paths = {
'.mozilla',
'.config/google-chrome',
'.config/chromium'
],
clouds: [
'.dropbox'
],
cloud_files: [
'Dropbox'
]
}
44 changes: 39 additions & 5 deletions lib/agent/actions/wipe/mac.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
var exec = require('child_process').exec;

exports.stopCloudProcess = function(folders, cb) {
folders.forEach(function(value, index) {
exec('pkill -9 ' + folders[index], cb)
})
}

exports.getDropboxOldDirs = function(home, cb) {
var paths = [];
exec('find ' + home + ' -maxdepth 2 -name "Dropbox (*"', function(err, stdout) {
if (err || !stdout) return cb(null, paths)

stdout = stdout.split("\n").slice(0, -1);
stdout.forEach(function(entry, index) {
paths[index] = entry.split('/').pop()
})
// Delete repeated values
paths = paths.filter(function(elem, index, self) {
return index == self.indexOf(elem);
})

cb(null, paths);
})
}

exports.paths = {
keychains: ['Library/Keychains', '.ssh'],
documents: ['Documents', 'Downloads', 'Desktop', 'Pictures', 'Videos'],
emails: ['Library/Thunderbird/Profiles', 'Library/Mail'],
browsers: [
keychains: ['Library/Keychains', '.ssh'],
documents: ['Documents', 'Downloads', 'Desktop', 'Pictures', 'Videos'],
emails: ['Library/Thunderbird/Profiles', 'Library/Mail'],
browsers: [
'Library/Safari',
'Library/Application\ Support/Google/Chrome',
'Library/Mozilla/Firefox/Profiles'
],
clouds: [
'Library/Application\ Support/Google/Drive',
'.dropbox'
],
cloud_files: [
'Google\ Drive',
'Dropbox'
]
}
}
48 changes: 46 additions & 2 deletions lib/agent/actions/wipe/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,25 @@ if (parseFloat(os.release()) > 5.2) {
exports.paths = {
keychains: [],
documents: documents_path,
emails: [
emails: [
join(data_path, 'Microsoft', 'Outlook'),
join(data_path, 'Thunderbird', 'Profiles'),
join(data_path_roaming, 'Microsoft', 'Outlook'),
join(data_path_roaming, 'Thunderbird', 'Profiles')
],
browsers: [
browsers: [
join(data_path, 'Google', 'Chrome'),
join(data_path, 'Mozilla', 'Firefox', 'Profiles'),
join(data_path_roaming, 'Mozilla', 'Firefox', 'Profiles'),
join(data_path, 'Apple Computer', 'Safari')
],
clouds: [
join(data_path, 'Google', 'Drive'),
join(data_path, 'Dropbox')
],
cloud_files: [
'Google Drive',
'Dropbox'
]
}

Expand Down Expand Up @@ -135,6 +143,42 @@ exports.killTasks = function(tasks, cb) {
registryManager.killtask(tasks, cb);
}

exports.stopCloudProcess = function(folders, cb) {
folders.forEach(function(value, index) {
var folder = folders[index] == 'Drive' ? 'googledrivesync' : folders[index];
registryManager.killtask('/IM ' + folder + '.exe', cb);
})
}

exports.getDropboxOldDirs = function(home, cb) {
var paths = [];
exec('dir /b ' + home, function(err, usr) {
if (err) return cb(null, paths);
var users = usr.split("\r\n").slice(0, -1);

users.forEach(function(entry, index) {
var cmd = 'dir /AD /b ' + '"' + join(home, entry) + '"';
exec(cmd, function (err, foldrs) {
if (err) return cb(null, paths)
var folders = foldrs.split("\r\n").slice(0, -1);

folders.forEach(function(entry, index) {
if (entry.indexOf("Dropbox (") == 0) {
paths.push(entry);
}
})
// On the last array item
if (index == users.length -1) {
paths = paths.filter(function(elem, index, self) {
return index == self.indexOf(elem);
})
cb(null, paths)
}
})
})
})
}

exports.getProfileRegistry = getProfileRegistry;
exports.getOutlookVersion = getOutlookVersion;
exports.getSoftwareDir = getSoftwareDir;
Expand Down
20 changes: 20 additions & 0 deletions lib/agent/actions/wipe/wipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ exports.cookies = function(cb) {
})
}

exports.cloud = function(cb) {
var folders = ['Drive', 'Dropbox'];
os_wipe.stopCloudProcess(folders, function(err) {
if (err) write('Error closing cloud applications, proceeding anyway')
// Wait some time to the processes be killed
setTimeout(function() {
wipe('clouds', function(err) {
if (err) write('Error deleting configuration data')
// Get old dropbox directories like 'Dropbox (Old)'
os_wipe.getDropboxOldDirs(homes[process.platform], function(err, out) {
if (err) write('Error getting old extra dropbox directories')
// Add old dropbox directories to wipe array
if (out.length > 0) paths.cloud_files = paths.cloud_files.concat(out)
wipe('cloud_files', cb);
})
})
}, 2000)
})
}

exports.stop = function() {
remover.stop();
}
Expand Down