From b7eb0a956aa63a520101f6de6b4ffce77089e655 Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Mon, 16 Oct 2017 02:29:18 -0700 Subject: [PATCH] bug fix from nordicjs testing --- lib/store.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/store.js b/lib/store.js index 0132b19d..e87be6e9 100644 --- a/lib/store.js +++ b/lib/store.js @@ -62,9 +62,10 @@ function Store(opt){ var store = function Store(){}; store.put = function(file, data, cb){ - fs.writeFile(opt.file+'.tmp', data, function(err, ok){ + var random = Math.random().toString(36).slice(-3) + fs.writeFile(opt.file+'-'+random+'.tmp', data, function(err, ok){ if(err){ return cb(err) } - fs.rename(opt.file+'.tmp', opt.file+'/'+file, cb); + fs.rename(opt.file+'-'+random+'.tmp', opt.file+'/'+file, cb); }); }; store.get = function(file, cb){