Skip to content

Commit

Permalink
Fix the purge
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolab committed May 14, 2017
1 parent 169e954 commit f4a2879
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions lib/purge.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const localHistoryPath = utils.getLocalHistoryPath();

/**
* Remove empty directories (asynchronous).
*
*
* @param {array} directories Array of directory paths to remove if empty.
* @param {object} onError Error handler
*/
Expand Down Expand Up @@ -48,7 +48,7 @@ class Purge {

/**
* Error handler.
*
*
* @param {object} error Error object
* @param {string} revFilePath Revision file path
*/
Expand All @@ -61,7 +61,7 @@ class Purge {
rawTitle: true
});

message = '- Can not purge the local history: <em>'
message = '- Can not purge the local history: <em>'
+ localHistoryPath + '</em>'
;

Expand All @@ -75,12 +75,12 @@ class Purge {
messages.attach();
messages.add(new PlainMessageView({message, raw: true}));

atom.emit('local-history:error-purge', report);
console.error('local-history:error-purge', report);
}

/**
* Add a revision in the `files` container.
*
*
* @param {object} files Files container
* @param {string} revFilePath Revision file path
* @return {object} Returns `files` container with `revFilePath` added inside
Expand All @@ -107,7 +107,7 @@ class Purge {

/**
* Purge expired revisions (asynchronous).
*
*
* @param {object} files A container of revision `files`.
* @return {Promise|number} The `Promise` of last removed file(s) number.
* @see Purge.addRevFile()
Expand Down Expand Up @@ -173,12 +173,12 @@ class Purge {
return fs.statAsync(filePath).then((stat) => {
if (stat.isDirectory()) {
onDirectory && onDirectory(filePath);

return this.scanDir(filePath, onFile, onDirectory);
}

onFile && onFile(filePath);

return filePath;
});
})
Expand All @@ -188,7 +188,7 @@ class Purge {

/**
* Purge a directory (recursive and asynchronous).
*
*
* @param {string} dirPath See `Purge.scanDir()`
* @param {function} [onFile] See `Purge.scanDir()`
* @param {function} [onDirectory] See `Purge.scanDir()`
Expand Down Expand Up @@ -219,8 +219,8 @@ class Purge {

return this
.purgeDir(
localHistoryPath,
null,
localHistoryPath,
null,
(dirPath) => directories.push(dirPath)
)
.then(() => removeEmptyDirectories(directories, this.onError))
Expand All @@ -231,11 +231,11 @@ class Purge {

/**
* Purge the old revisions files of local history.
*
*
* @see Purge.run()
*/
module.exports = function purge() {
let p = new Purge();

p.run();
};
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const utils = {
let basePath = path.basename(filePath);
let splitPath = basePath.split('_');
let date = splitPath[0];
let time = splitPath[1].split('-');
let time = splitPath[1] ? splitPath[1].split('-') : ['00', '00', '00'];

time = time[0] + ':' + time[1] + ':' + time[2];
return date + ' ' + time;
Expand Down

0 comments on commit f4a2879

Please sign in to comment.