Skip to content

Commit

Permalink
Merge pull request #327 from prey/1.7.1-fixes
Browse files Browse the repository at this point in the history
Location, webcam and wipe fixes
  • Loading branch information
javo authored Sep 5, 2017
2 parents 20a1656 + ee2348c commit 87143b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
19 changes: 10 additions & 9 deletions lib/agent/actions/wipe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ exports.start = function(opts, cb) {
removed = 0;

// runs it within this context, unlike the spawn option
var queue = function(method) {
var queue = function(error, method) {
queued++;
wipe[method](function(err, removed) {
if (err) last_err = err;
if (typeof wipe[method] == 'function') {
wipe[method](function(err, removed) {
if (err) last_err = err;

removed += removed;
--queued || finished(last_err);
})
removed += removed;
--queued || finished(last_err);
})
} else return finished(error);
}

// run it as another process, using impersonation (to avoid permission errors)
Expand All @@ -67,10 +69,9 @@ exports.start = function(opts, cb) {
if (err) {
if (err.toString().includes('No logged user') && os_name == 'windows') {
logger.warn('Not logged user found, proceding without impersonation')
queue(items);
return queue(err, items);
}
else
return finished(err);
else return finished(err);
}

child.stdout.on('data', function(str) {
Expand Down
4 changes: 3 additions & 1 deletion lib/agent/providers/webcam/windows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ exports.get_picture = function(file, callback){
})
}

take_picture(0);
fs.unlink(file, function() {
take_picture(0);
})

}
6 changes: 3 additions & 3 deletions lib/agent/triggers/location/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var trigger_event = function(type, new_location) {

if (Object.keys(current).length == 0) {
current = new_location;

return emitter.emit(event, new_location);
}

Expand All @@ -26,7 +25,7 @@ var trigger_event = function(type, new_location) {
new_location.delta = distance;
current = new_location;

emitter.emit(event, new_location);
hooks.emit(event, new_location);
}

var fetch_location = function(type, callback) {
Expand All @@ -43,7 +42,8 @@ var fetch_location = function(type, callback) {

checking = true;
geo.fetch_location(function(err, coords) {
if (err || !coords || !emitter) return done(err);
if (err || !coords || !emitter)
return done(new Error('Unable to get location'));

done(null, coords);
trigger_event(type, coords);
Expand Down
2 changes: 1 addition & 1 deletion test/lib/agent/providers/geo/wifi_strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('location', function() {

it('works', function(done) {
provider_stub.restore();
this.timeout(5000); // response may take longer
this.timeout(6000); // response may take longer

wifi_strat(function(err, data) {
if (err) {
Expand Down

0 comments on commit 87143b4

Please sign in to comment.