@secrez/fs 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/InternalFs.js CHANGED
@@ -1,449 +1,463 @@
1
- const util = require('util')
2
- const path = require('path')
3
- const fs = require('fs-extra')
4
- const {config, Entry, ConfigUtils} = require('@secrez/core')
5
- const Node = require('./Node')
6
- const Tree = require('./Tree')
7
- const {ENTRY_EXISTS} = require('./Messages')
1
+ const util = require("util");
2
+ const path = require("path");
3
+ const fs = require("fs-extra");
4
+ const { config, Entry, ConfigUtils } = require("@secrez/core");
5
+ const Node = require("./Node");
6
+ const Tree = require("./Tree");
7
+ const { ENTRY_EXISTS } = require("./Messages");
8
8
 
9
9
  class InternalFs {
10
-
11
10
  constructor(secrez) {
12
- if (secrez.constructor.name === 'Secrez') {
13
- this.secrez = secrez
14
- this.dataPath = secrez.config.dataPath
15
- this.trees = [new Tree(secrez), new Tree(secrez, 1)]
16
- this.treeIndex = 0
17
- this.tree = this.trees[0]
11
+ if (secrez.constructor.name === "Secrez") {
12
+ this.secrez = secrez;
13
+ this.dataPath = secrez.config.dataPath;
14
+ this.trees = [new Tree(secrez), new Tree(secrez, 1)];
15
+ this.treeIndex = 0;
16
+ this.tree = this.trees[0];
18
17
  } else {
19
- throw new Error('InternalFs requires a Secrez instance during construction')
18
+ throw new Error(
19
+ "InternalFs requires a Secrez instance during construction"
20
+ );
20
21
  }
21
22
  }
22
23
 
23
24
  async init() {
24
25
  // eslint-disable-next-line require-atomic-updates
25
- await this.tree.load()
26
- await this.trashToBeDeleted(0)
26
+ await this.tree.load();
27
+ await this.trashToBeDeleted(0);
27
28
  }
28
29
 
29
30
  getFullPath(entry) {
30
- return path.join(this.dataPath, entry.encryptedName)
31
+ return path.join(this.dataPath, entry.encryptedName);
31
32
  }
32
33
 
33
34
  cleanPreviousRootEntry() {
34
35
  for (let t of this.trees) {
35
- delete t.previousRootEntry
36
+ delete t.previousRootEntry;
36
37
  }
37
38
  }
38
39
 
39
40
  async make(options) {
40
- let data = await this.getTreeIndexAndPath(options.path)
41
- options.path = data.path
42
- let tree = data.tree
43
- let p = this.normalizePath(options.path)
41
+ let data = await this.getTreeIndexAndPath(options.path);
42
+ options.path = data.path;
43
+ let tree = data.tree;
44
+ let p = this.normalizePath(options.path);
44
45
  if (Node.isFile(options) && options.versionIfExists) {
45
- p = path.join(path.dirname(p), await tree.getVersionedBasename(p))
46
+ p = path.join(path.dirname(p), await tree.getVersionedBasename(p));
46
47
  }
47
- let [ancestor, remainingPath] = tree.root.getChildFromPath(p, true)
48
- p = remainingPath.split('/')
49
- let len = p.length
50
- let child
48
+ let [ancestor, remainingPath] = tree.root.getChildFromPath(p, true);
49
+ p = remainingPath.split("/");
50
+ let len = p.length;
51
+ let child;
51
52
  for (let i = 0; i < len; i++) {
52
- let notLast = i < len - 1
53
+ let notLast = i < len - 1;
53
54
  let entry = new Entry({
54
55
  id: options.id,
55
56
  name: p[i],
56
- type: notLast ? config.types.DIR : options.type
57
- })
57
+ type: notLast ? config.types.DIR : options.type,
58
+ });
58
59
  if (Node.isFile(options) && options.content) {
59
- entry.set({content: options.content})
60
+ entry.set({ content: options.content });
60
61
  }
61
- child = await tree.add(ancestor, entry)
62
+ child = await tree.add(ancestor, entry);
62
63
  if (notLast) {
63
- ancestor = child
64
+ ancestor = child;
64
65
  }
65
66
  }
66
- return child
67
+ return child;
67
68
  }
68
69
 
69
70
  normalizePath(p, index) {
70
- if (!p || typeof p !== 'string') {
71
- throw new Error('The "path" option must exist and be of type string')
71
+ if (!p || typeof p !== "string") {
72
+ throw new Error('The "path" option must exist and be of type string');
72
73
  }
73
- p = p.replace(/^~\/+/, '/').replace(/~+/g, '')
74
- let tree = index ? this.trees[index] : this.tree
75
- p = path.resolve(tree.workingNode.getPath(), p)
76
- for (let v of p.split('/')) {
74
+ p = p.replace(/^~\/+/, "/").replace(/~+/g, "");
75
+ let tree = index ? this.trees[index] : this.tree;
76
+ p = path.resolve(tree.workingNode.getPath(), p);
77
+ for (let v of p.split("/")) {
77
78
  if (v.length > 255) {
78
- throw new Error('File names cannot be longer that 255 characters')
79
+ throw new Error("File names cannot be longer that 255 characters");
79
80
  }
80
81
  }
81
- return Entry.sanitizePath(p)
82
+ return Entry.sanitizePath(p);
82
83
  }
83
84
 
84
85
  async getIndexes(options = {}) {
85
- let indexFrom = this.treeIndex
86
- let indexTo = this.treeIndex
87
- let foundFrom
88
- let foundTo
86
+ let indexFrom = this.treeIndex;
87
+ let indexTo = this.treeIndex;
88
+ let foundFrom;
89
+ let foundTo;
89
90
 
90
91
  if (options.to || options.from) {
91
- for (let dataset of (await this.getDatasetsInfo())) {
92
- if (dataset.name.toLowerCase() === (options.to || '').toLowerCase()) {
93
- indexTo = dataset.index
94
- foundTo = true
92
+ for (let dataset of await this.getDatasetsInfo()) {
93
+ if (dataset.name.toLowerCase() === (options.to || "").toLowerCase()) {
94
+ indexTo = dataset.index;
95
+ foundTo = true;
95
96
  }
96
- if (dataset.name.toLowerCase() === (options.from || '').toLowerCase()) {
97
- indexFrom = dataset.index
98
- foundFrom = true
97
+ if (dataset.name.toLowerCase() === (options.from || "").toLowerCase()) {
98
+ indexFrom = dataset.index;
99
+ foundFrom = true;
99
100
  }
100
101
  }
101
102
  if ((options.to && !foundTo) || (options.from && !foundFrom)) {
102
- throw new Error('Target dataset does not exist')
103
+ throw new Error("Target dataset does not exist");
103
104
  }
104
105
  }
105
- return [indexFrom, indexTo]
106
+ return [indexFrom, indexTo];
106
107
  }
107
108
 
108
109
  async change(options = {}) {
109
- if (!options.newPath && typeof options.content !== 'undefined') {
110
- options.newPath = options.path
111
- }
112
- let dataFrom = await this.getTreeIndexAndPath(options.path)
113
- let indexFrom = dataFrom.index
114
- let treeFrom = dataFrom.tree
115
- options.path = dataFrom.path
116
- let dataTo = await this.getTreeIndexAndPath(options.newPath)
117
- let indexTo = dataTo.index
118
- let treeTo = dataTo.tree
119
- options.newPath = dataTo.path
110
+ if (!options.newPath && typeof options.content !== "undefined") {
111
+ options.newPath = options.path;
112
+ }
113
+ let dataFrom = await this.getTreeIndexAndPath(options.path);
114
+ let indexFrom = dataFrom.index;
115
+ let treeFrom = dataFrom.tree;
116
+ options.path = dataFrom.path;
117
+ let dataTo = await this.getTreeIndexAndPath(options.newPath);
118
+ let indexTo = dataTo.index;
119
+ let treeTo = dataTo.tree;
120
+ options.newPath = dataTo.path;
120
121
 
121
- let cross = indexTo !== indexFrom
122
- let fromTrash = options.removing && indexFrom === 1
122
+ let cross = indexTo !== indexFrom;
123
+ let fromTrash = options.removing && indexFrom === 1;
123
124
 
124
- let p = this.normalizePath(options.path, indexFrom)
125
- let n
125
+ let p = this.normalizePath(options.path, indexFrom);
126
+ let n;
126
127
 
127
128
  if (options.newPath) {
128
- n = this.normalizePath(options.newPath, indexTo)
129
+ n = this.normalizePath(options.newPath, indexTo);
129
130
  if (p === n && indexFrom === indexTo) {
130
- n = undefined
131
+ n = undefined;
131
132
  }
132
133
  }
133
134
 
134
- let node
135
+ let node;
135
136
  try {
136
- node = treeFrom.root.getChildFromPath(p)
137
- } catch (e) {
138
- }
137
+ node = treeFrom.root.getChildFromPath(p);
138
+ } catch (e) {}
139
139
  if (!node) {
140
- throw new Error('Path does not exist')
140
+ throw new Error("Path does not exist");
141
141
  }
142
- let originalParentId = node.parent.id
143
- let entry = new Entry(Object.assign(options, node.getEntry()))
144
- let ancestor, remainingPath
142
+ let originalParentId = node.parent.id;
143
+ let entry = new Entry(Object.assign(options, node.getEntry()));
144
+ let ancestor, remainingPath;
145
145
  try {
146
- let result = n ? treeTo.root.getChildFromPath(n, true) : []
147
- ancestor = result[0]
148
- remainingPath = result[1]
146
+ let result = n ? treeTo.root.getChildFromPath(n, true) : [];
147
+ ancestor = result[0];
148
+ remainingPath = result[1];
149
149
  } catch (e) {
150
150
  if (e.message === util.format(ENTRY_EXISTS, path.basename(n))) {
151
- let dir = treeTo.root.getChildFromPath(n)
151
+ let dir = treeTo.root.getChildFromPath(n);
152
152
  if (dir && Node.isDir(dir)) {
153
- ancestor = dir
154
- remainingPath = path.basename(p)
153
+ ancestor = dir;
154
+ remainingPath = path.basename(p);
155
155
  }
156
156
  }
157
157
  }
158
158
  if (ancestor) {
159
- remainingPath = remainingPath.split('/')
159
+ remainingPath = remainingPath.split("/");
160
160
  if (remainingPath.length > 1) {
161
- throw new Error('Cannot move a node to a not existing folder')
161
+ throw new Error("Cannot move a node to a not existing folder");
162
162
  }
163
- entry.name = remainingPath[0]
163
+ entry.name = remainingPath[0];
164
164
  if (ancestor.id !== node.parent.id || cross) {
165
- entry.parent = ancestor
165
+ entry.parent = ancestor;
166
166
  }
167
167
  }
168
168
 
169
169
  if (Node.isFile(entry)) {
170
- node.content = (await treeFrom.getEntryDetails(node)).content
171
- if (typeof entry.content === 'undefined') {
172
- entry.content = node.content
170
+ node.content = (await treeFrom.getEntryDetails(node)).content;
171
+ if (typeof entry.content === "undefined") {
172
+ entry.content = node.content;
173
173
  }
174
174
  }
175
175
 
176
176
  if (!n && !cross && entry.content === node.content) {
177
- return node
177
+ return node;
178
178
  }
179
- entry.preserveContent = true
179
+ entry.preserveContent = true;
180
180
 
181
- if (entry.parent && (!node.parent || entry.parent.id !== node.parent.id || cross)) {
182
- entry.name = await treeTo.getVersionedBasename(path.join(entry.parent.getPath(), entry.name), entry.parent)
181
+ if (
182
+ entry.parent &&
183
+ (!node.parent || entry.parent.id !== node.parent.id || cross)
184
+ ) {
185
+ entry.name = await treeTo.getVersionedBasename(
186
+ path.join(entry.parent.getPath(), entry.name),
187
+ entry.parent
188
+ );
183
189
  }
184
190
  if (entry.name !== node.getName() || entry.content !== node.getContent()) {
185
- entry = this.secrez.encryptEntry(entry)
186
- await treeFrom.saveEntry(entry)
191
+ entry = this.secrez.encryptEntry(entry);
192
+ await treeFrom.saveEntry(entry);
187
193
  }
188
194
 
189
195
  if (cross || fromTrash) {
190
-
191
- await this.moveOrUnlink(node, indexFrom, indexTo, fromTrash, entry)
192
- let originalParent = treeFrom.root.findChildById(originalParentId, true)
193
- originalParent.removeChild(node)
196
+ await this.moveOrUnlink(node, indexFrom, indexTo, fromTrash, entry);
197
+ let originalParent = treeFrom.root.findChildById(originalParentId, true);
198
+ originalParent.removeChild(node);
194
199
  if (cross) {
195
- entry.parent.add(node)
200
+ entry.parent.add(node);
196
201
  }
197
- await treeFrom.save()
198
- await treeTo.save()
199
-
202
+ await treeFrom.save();
203
+ await treeTo.save();
200
204
  } else {
201
-
202
- node.move(entry)
203
- await treeFrom.save()
205
+ node.move(entry);
206
+ await treeFrom.save();
204
207
  }
205
- return node
208
+ return node;
206
209
  }
207
210
 
208
211
  async moveOrUnlink(node, indexFrom, indexTo, unlink, entry) {
209
212
  if (entry && node.getName() !== entry.name) {
210
- node.move(entry)
211
- await this.trees[indexFrom].save()
212
- }
213
- let allFiles = await this.trees[indexFrom].getAllDataFiles(node)
214
- let fromDatapath = ConfigUtils.getDatasetPath(this.secrez.config, indexFrom)
215
- let toDatapath = ConfigUtils.getDatasetPath(this.secrez.config, indexTo)
213
+ node.move(entry);
214
+ await this.trees[indexFrom].save();
215
+ }
216
+ let allFiles = await this.trees[indexFrom].getAllDataFiles(node);
217
+ let fromDatapath = ConfigUtils.getDatasetPath(
218
+ this.secrez.config,
219
+ indexFrom
220
+ );
221
+ let toDatapath = ConfigUtils.getDatasetPath(this.secrez.config, indexTo);
216
222
  for (let file of allFiles) {
217
223
  if (await fs.pathExists(path.join(fromDatapath, file))) {
218
224
  if (unlink) {
219
- await fs.unlink(path.join(fromDatapath, file))
225
+ await fs.unlink(path.join(fromDatapath, file));
220
226
  } else {
221
- await fs.move(path.join(fromDatapath, file), path.join(toDatapath, file))
227
+ await fs.move(
228
+ path.join(fromDatapath, file),
229
+ path.join(toDatapath, file)
230
+ );
222
231
  }
223
232
  }
224
233
  }
225
234
  }
226
235
 
227
236
  async remove(options = {}, node) {
228
- return await this.change(Object.assign(
229
- options, {
230
- removing: true,
231
- to: 'trash',
232
- newPath: '/'
233
- }
234
- ))
237
+ return await this.change(
238
+ Object.assign(options, {
239
+ removing: true,
240
+ to: "trash",
241
+ newPath: "/",
242
+ })
243
+ );
235
244
  }
236
245
 
237
- async getTreeIndexAndPath(p = './') {
246
+ async getTreeIndexAndPath(p = "./") {
238
247
  let data = {
239
248
  tree: this.tree,
240
249
  name: this.tree.name,
241
250
  index: this.treeIndex,
242
- path: p || './'
243
- }
244
- let datasetAndPath = p.split(':')
251
+ path: p || "./",
252
+ };
253
+ let datasetAndPath = p.split(":");
245
254
  if (datasetAndPath.length > 1) {
246
- let dataset = await this.getDatasetInfo(datasetAndPath[0])
255
+ let dataset = await this.getDatasetInfo(datasetAndPath[0]);
247
256
  if (dataset === false) {
248
- throw new Error('Dataset not found')
257
+ throw new Error("Dataset not found");
249
258
  } else if (dataset.index !== this.treeIndex) {
250
- await this.mountTree(dataset.index)
251
- data.index = dataset.index
252
- data.tree = this.trees[dataset.index]
253
- data.name = this.trees[dataset.index].name
259
+ await this.mountTree(dataset.index);
260
+ data.index = dataset.index;
261
+ data.tree = this.trees[dataset.index];
262
+ data.name = this.trees[dataset.index].name;
254
263
  }
255
- data.path = datasetAndPath[1] || './'
256
- data.updated = true
264
+ data.path = datasetAndPath[1] || "./";
265
+ data.updated = true;
257
266
  }
258
- return data
267
+ return data;
259
268
  }
260
269
 
261
270
  async getFileList(options = {}, addSlashIfDir, returnNodes) {
262
271
  try {
263
- return await this.fileList(options, addSlashIfDir, returnNodes)
272
+ return await this.fileList(options, addSlashIfDir, returnNodes);
264
273
  } catch (e) {
265
- return []
274
+ return [];
266
275
  }
267
276
  }
268
277
 
269
278
  async fileList(options = {}, addSlashIfDir, returnNodes) {
270
- if (typeof options === 'string') {
271
- options = {path: options}
279
+ if (typeof options === "string") {
280
+ options = { path: options };
272
281
  }
273
282
  if (Array.isArray(options.path)) {
274
- options.path = options.path[options.path.length - 1]
283
+ options.path = options.path[options.path.length - 1];
275
284
  }
276
- let data = await this.getTreeIndexAndPath(options.path)
285
+ let data = await this.getTreeIndexAndPath(options.path);
277
286
  // console.log(data)
278
- let datasets = []
287
+ let datasets = [];
279
288
  if (!data.updated && !options.ignoreDatasets) {
280
289
  datasets = (await this.getDatasetsInfo())
281
- .map(e => e.name)
282
- .filter(e => RegExp('^' + (options.path || '').replace(/\*/g, '\\*').replace(/\?/g, '\\?')).test(e))
283
- .map(e => e + ':/')
284
- }
285
- let tree = data.tree
286
- let files = data.path
287
- let p = tree.getNormalizedPath(files)
288
- let end = path.basename(p)
289
- let node
290
+ .map((e) => e.name)
291
+ .filter((e) =>
292
+ RegExp(
293
+ "^" +
294
+ (options.path || "").replace(/\*/g, "\\*").replace(/\?/g, "\\?")
295
+ ).test(e)
296
+ )
297
+ .map((e) => e + ":/");
298
+ }
299
+ let tree = data.tree;
300
+ let files = data.path;
301
+ let p = tree.getNormalizedPath(files);
302
+ let end = path.basename(p);
303
+ let node;
290
304
  if (!/\?|\*/.test(end)) {
291
- end = undefined
305
+ end = undefined;
292
306
  }
293
307
  try {
294
308
  if (/\?|\*/.test(path.basename(p))) {
295
- throw new Error()
309
+ throw new Error();
296
310
  }
297
- node = tree.root.getChildFromPath(p)
311
+ node = tree.root.getChildFromPath(p);
298
312
  } catch (e) {
299
- end = path.basename(p)
300
- node = tree.root.getChildFromPath(path.dirname(p))
313
+ end = path.basename(p);
314
+ node = tree.root.getChildFromPath(path.dirname(p));
301
315
  }
302
- const getType = n => {
316
+ const getType = (n) => {
303
317
  if (addSlashIfDir) {
304
- return Node.isDir(n) ? '/' : ''
318
+ return Node.isDir(n) ? "/" : "";
305
319
  }
306
- return ''
307
- }
320
+ return "";
321
+ };
308
322
  if (node) {
309
- if (Node.isFile(node) || (options.asIs && !end)
310
- ) {
311
- if ((Node.isFile(node) && options.only === 'd') || (Node.isDir(node) && options.only === 'f')) {
312
- return []
323
+ if (Node.isFile(node) || (options.asIs && !end)) {
324
+ if (
325
+ (Node.isFile(node) && options.only === "d") ||
326
+ (Node.isDir(node) && options.only === "f")
327
+ ) {
328
+ return [];
313
329
  }
314
- return returnNodes
315
- ? [node]
316
- : [getType(node) + node.getName()]
330
+ return returnNodes ? [node] : [getType(node) + node.getName()];
317
331
  } else {
318
- let children = returnNodes ? [] : datasets
332
+ let children = returnNodes ? [] : datasets;
319
333
  for (let id in node.children) {
320
- let child = node.children[id]
321
- if ((Node.isFile(child) && options.only === 'd') || (Node.isDir(child) && options.only === 'f')) {
322
- continue
334
+ let child = node.children[id];
335
+ if (
336
+ (Node.isFile(child) && options.only === "d") ||
337
+ (Node.isDir(child) && options.only === "f")
338
+ ) {
339
+ continue;
323
340
  }
324
- children.push(
325
- returnNodes
326
- ? child
327
- : child.getName() + getType(child)
328
- )
341
+ children.push(returnNodes ? child : child.getName() + getType(child));
329
342
  }
330
343
  if (end) {
331
- end = '^' + end
332
- .replace(/\?/g, '.{1}')
333
- .replace(/\*/g, '.*')
334
- .replace(/\\ /g, ' ')
335
- + (options.forAutoComplete ? '' : '(|\\/)$')
336
- let re = RegExp(end)
337
- children = children.filter(e => {
338
- return re.test(
339
- returnNodes
340
- ? e.getName()
341
- : e
342
- )
343
- })
344
+ end =
345
+ "^" +
346
+ end
347
+ .replace(/\?/g, ".{1}")
348
+ .replace(/\*/g, ".*")
349
+ .replace(/\\ /g, " ") +
350
+ (options.forAutoComplete ? "" : "(|\\/)$");
351
+ let re = RegExp(end);
352
+ children = children.filter((e) => {
353
+ return re.test(returnNodes ? e.getName() : e);
354
+ });
344
355
  }
345
- return children
356
+ return children;
346
357
  }
347
358
  }
348
- return []
359
+ return [];
349
360
  }
350
361
 
351
362
  async mountTrash() {
352
- await this.mountTree(1)
353
- return this.trees[1]
363
+ await this.mountTree(1);
364
+ return this.trees[1];
354
365
  }
355
366
 
356
367
  async trashToBeDeleted(index) {
357
- let trash = await this.mountTrash()
358
- let tree = this.trees[index]
359
- let fromTrash = index === 1
368
+ let trash = await this.mountTrash();
369
+ let tree = this.trees[index];
370
+ let fromTrash = index === 1;
360
371
  if (tree.toBeDeleted.length) {
361
372
  for (let node of tree.toBeDeleted) {
362
373
  if (!fromTrash) {
363
- trash.root.add(node)
374
+ trash.root.add(node);
364
375
  }
365
- await this.moveOrUnlink(node, index, 1, fromTrash)
376
+ await this.moveOrUnlink(node, index, 1, fromTrash);
366
377
  }
367
- await tree.save()
368
- await trash.save()
369
- tree.toBeDeleted = []
378
+ await tree.save();
379
+ await trash.save();
380
+ tree.toBeDeleted = [];
370
381
  }
371
382
  }
372
383
 
373
384
  async mountTree(index, makeActive) {
374
385
  if (!this.trees[index]) {
375
- this.trees[index] = new Tree(this.secrez, index)
386
+ this.trees[index] = new Tree(this.secrez, index);
376
387
  }
377
388
  if (this.trees[index].status !== Tree.statutes.LOADED) {
378
- await this.trees[index].load()
379
- await this.trashToBeDeleted(index)
389
+ await this.trees[index].load();
390
+ await this.trashToBeDeleted(index);
380
391
  }
381
392
  if (makeActive) {
382
- this.tree = this.trees[index]
383
- this.treeIndex = index
393
+ this.tree = this.trees[index];
394
+ this.treeIndex = index;
384
395
  }
385
396
  }
386
397
 
387
398
  async getDatasetsInfo() {
388
- let result = [{
389
- index: 0,
390
- name: 'main'
391
- }, {
392
- index: 1,
393
- name: 'trash'
394
- }]
399
+ let result = [
400
+ {
401
+ index: 0,
402
+ name: "main",
403
+ },
404
+ {
405
+ index: 1,
406
+ name: "trash",
407
+ },
408
+ ];
395
409
  if (!this.treeCache) {
396
- this.treeCache = []
410
+ this.treeCache = [];
397
411
  }
398
- let datasets = ConfigUtils.listDatasets(this.secrez.config)
412
+ let datasets = ConfigUtils.listDatasets(this.secrez.config);
399
413
  if (datasets.length > 2) {
400
414
  for (let i = 2; i < datasets.length; i++) {
401
- let name
415
+ let name;
402
416
  if (this.trees[i]) {
403
- name = this.trees[i].name
417
+ name = this.trees[i].name;
404
418
  } else if (this.treeCache[i]) {
405
- name = this.treeCache[i]
419
+ name = this.treeCache[i];
406
420
  } else {
407
- let tree = new Tree(this.secrez, i)
408
- name = await tree.getName()
409
- this.treeCache[i] = name
421
+ let tree = new Tree(this.secrez, i);
422
+ name = await tree.getName();
423
+ this.treeCache[i] = name;
410
424
  }
411
425
  result.push({
412
426
  index: i,
413
- name
414
- })
427
+ name,
428
+ });
415
429
  }
416
430
  }
417
- return result
431
+ return result;
418
432
  }
419
433
 
420
434
  async deleteDataset(index) {
421
435
  if (ConfigUtils.deleteDataset(this.secrez.config, index)) {
422
- delete this.trees[index]
423
- this.deleteFromTreeCache(index)
424
- return true
436
+ delete this.trees[index];
437
+ this.deleteFromTreeCache(index);
438
+ return true;
425
439
  } else {
426
- return false
440
+ return false;
427
441
  }
428
442
  }
429
443
 
430
444
  async getDatasetInfo(name) {
431
- let datasets = await this.getDatasetsInfo()
445
+ let datasets = await this.getDatasetsInfo();
432
446
  for (let dataset of datasets) {
433
447
  if (dataset.name.toLowerCase() === name.toLowerCase()) {
434
- return dataset
448
+ return dataset;
435
449
  }
436
450
  }
437
- return false
451
+ return false;
438
452
  }
439
453
 
440
454
  updateTreeCache(index, name) {
441
- this.treeCache[index] = name
455
+ this.treeCache[index] = name;
442
456
  }
443
457
 
444
458
  deleteFromTreeCache(index) {
445
- delete this.treeCache[index]
459
+ delete this.treeCache[index];
446
460
  }
447
461
  }
448
462
 
449
- module.exports = InternalFs
463
+ module.exports = InternalFs;