Skip to content

Commit

Permalink
Desktop app: properly save teams to alternate paths
Browse files Browse the repository at this point in the history
If the Documents folder was unexistent, Storage would not work at all
  • Loading branch information
Slayer95 committed Dec 5, 2013
1 parent 4dc5d34 commit 3db4ca6
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,19 @@ _Storage.prototype.initDirectory = function() {
var dir = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
if (!(dir.charAt(dir.length-1) in {'/':1, '\\':1})) dir += '/';
fs.stat(dir+'Documents', function(err, stats) {
if (err) return;
if (stats.isDirectory()) {
if (err || !stats.isDirectory()) {
fs.stat(dir+'My Documents', function(err, stats) {
if (err || !stats.isDirectory()) {
self.documentsDir = dir;
} else {
self.documentsDir = dir+'My Documents/';
}
self.initDirectory2();
});
} else {
self.documentsDir = dir+'Documents/';
self.initDirectory2();
return;
}
fs.stat(dir+'My Documents', function(err, stats) {
if (err) return;
if (stats.isDirectory()) {
self.documentsDir = dir+'My Documents/';
} else {
self.documentsDir = dir;
}
self.initDirectory2();
});
});
};

Expand Down

0 comments on commit 3db4ca6

Please sign in to comment.