Showing 1 of 1 files from the diff.

@@ -5,22 +5,30 @@
Loading
5 5
var ENCODING = {encoding: 'utf8'};
6 6
var RETRY_INTERVAL = 16000;
7 7
8 -
function readFileSafe(file) {
8 +
function readFileSafe(file, retry) {
9 9
  try {
10 10
    file = fs.readFileSync(file, ENCODING);
11 11
  } catch(e) {
12 -
    file = null;
12 +
    if (retry) {
13 +
      file = null;
14 +
    } else {
15 +
      return readFileSafe(file, true);
16 +
    }
13 17
  }
14 18
15 19
  return file || '';
16 20
}
17 21
18 -
function readJsonSafe(file) {
22 +
function readJsonSafe(file, retry) {
19 23
  try {
20 24
    file = fs.readFileSync(file, ENCODING);
21 25
    file = file && JSON.parse(file);
22 26
  } catch(e) {
23 -
    file = null;
27 +
    if (retry) {
28 +
      file = null;
29 +
    } else {
30 +
      return readJsonSafe(file, true);
31 +
    }
24 32
  }
25 33
26 34
  return file;
@@ -102,7 +110,18 @@
Loading
102 110
    };
103 111
  });
104 112
105 -
  var properties = readJsonSafe(self._properties) || readJsonSafe(self._backupProps) || {};
113 +
  var properties = readJsonSafe(self._properties);
114 +
  if (properties) {
115 +
    fse.outputJsonSync(self._backupProps, properties);
116 +
  } else {
117 +
    properties = readJsonSafe(self._backupProps);
118 +
    if (properties) {
119 +
      fse.outputJsonSync(self._properties, properties);
120 +
    } else {
121 +
      properties = {};
122 +
    }
123 +
  }
124 +
106 125
  self._cache = {
107 126
    maxIndex: maxIndex,
108 127
    files: files,
@@ -128,8 +147,6 @@
Loading
128 147
    return compare(cur.index, next.index);
129 148
  });
130 149
  this._cache.properties['filesOrder'] = filesOrder;
131 -
  fse.outputJsonSync(self._properties, self._cache.properties);
132 -
  fse.outputJsonSync(self._backupProps, self._cache.properties);
133 150
  fs.readdirSync(backupDir).forEach(function(file) {
134 151
    if (fileNames[file]) {
135 152
      return;
@@ -142,11 +159,18 @@
Loading
142 159
143 160
var proto = Storage.prototype;
144 161
145 -
function copyFile(src, dest, callback) {
162 +
function copyFile(src, dest, callback, retry) {
163 +
  var execCb = function(e) {
164 +
    if (e && !retry) {
165 +
      copyFile(src, dest, callback, true);
166 +
    } else {
167 +
      callback(e);
168 +
    }
169 +
  };
146 170
  if (typeof fs.copyFile === 'function') {
147 -
    fs.copyFile(src, dest, callback);
171 +
    fs.copyFile(src, dest, execCb);
148 172
  } else {
149 -
    fse.copy(src, dest, callback);
173 +
    fse.copy(src, dest, execCb);
150 174
  }
151 175
}
152 176
Files Coverage
biz 66.87%
lib 74.41%
index.js 87.50%
Project Totals (89 files) 73.93%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading