Skip to content

Instantly share code, notes, and snippets.

@artcommacode
Created August 27, 2012 10:34
Show Gist options
  • Save artcommacode/3487317 to your computer and use it in GitHub Desktop.
Save artcommacode/3487317 to your computer and use it in GitHub Desktop.
var fs = require('fs')
, async = require('async');
exports.newUpload = function(path, f) {
var i = 0
, p = path;
async.until(
function () {
p = (i !== 0) ? path + i : path;
fs.stat(p, function (error, stats) {
return error && error.code === 'ENOENT'
});
},
function (callback) {
i++;
callback();
},
function (error) {
console.dir(p);
f(error, p);
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment