mobiletto 1.0.27 → 1.0.28
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/drivers/local/index.js +12 -12
- package/drivers/s3/index.js +1 -1
- package/package.json +1 -1
package/drivers/local/index.js
CHANGED
|
@@ -11,14 +11,6 @@ const DEFAULT_MODE = '0700'
|
|
|
11
11
|
|
|
12
12
|
const isNotExistError = (err) => err.code && (err.code === 'ENOENT' || err.code === 'ENOTDIR')
|
|
13
13
|
|
|
14
|
-
const ioError = (err, path, method) => isNotExistError(err)
|
|
15
|
-
? err instanceof MobilettoNotFoundError
|
|
16
|
-
? err
|
|
17
|
-
: new MobilettoNotFoundError(path)
|
|
18
|
-
: err instanceof MobilettoError || err instanceof MobilettoNotFoundError
|
|
19
|
-
? err
|
|
20
|
-
: new MobilettoError(`${method}(${path}) error: ${err}`, err)
|
|
21
|
-
|
|
22
14
|
const fileType = (stat) => {
|
|
23
15
|
if (stat.isDirectory()) {
|
|
24
16
|
return M_DIR
|
|
@@ -67,6 +59,14 @@ class StorageClient {
|
|
|
67
59
|
const norm = path.startsWith(this.baseDir) ? path.substring(this.baseDir.length) : path
|
|
68
60
|
return norm.startsWith('/') ? norm.substring(1) : norm
|
|
69
61
|
}
|
|
62
|
+
ioError = (err, path, method) => isNotExistError(err)
|
|
63
|
+
? err instanceof MobilettoNotFoundError
|
|
64
|
+
? err
|
|
65
|
+
: new MobilettoNotFoundError(this.denormalizePath(path))
|
|
66
|
+
: err instanceof MobilettoError || err instanceof MobilettoNotFoundError
|
|
67
|
+
? err
|
|
68
|
+
: new MobilettoError(`${method}(${path}) error: ${err}`, err)
|
|
69
|
+
|
|
70
70
|
|
|
71
71
|
fileToObject = (dir) => (f) => {
|
|
72
72
|
const stat = fs.lstatSync(dir + '/' + f)
|
|
@@ -105,7 +105,7 @@ class StorageClient {
|
|
|
105
105
|
return files
|
|
106
106
|
} catch (e) {
|
|
107
107
|
console.error(`dirFiles: ${e}`)
|
|
108
|
-
throw ioError(e, norm, 'dirFiles')
|
|
108
|
+
throw this.ioError(e, norm, 'dirFiles')
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -120,7 +120,7 @@ class StorageClient {
|
|
|
120
120
|
return await this.readDirFiles(dir, recursive, visitor)
|
|
121
121
|
}
|
|
122
122
|
} catch (err) {
|
|
123
|
-
throw ioError(err, path, 'list')
|
|
123
|
+
throw this.ioError(err, path, 'list')
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
async metadata (path) {
|
|
@@ -144,7 +144,7 @@ class StorageClient {
|
|
|
144
144
|
mtime: lstat.mtimeMs
|
|
145
145
|
}
|
|
146
146
|
} catch (err) {
|
|
147
|
-
throw ioError(err, path, 'metadata')
|
|
147
|
+
throw this.ioError(err, path, 'metadata')
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -235,7 +235,7 @@ class StorageClient {
|
|
|
235
235
|
const stream = fs.createReadStream(file)
|
|
236
236
|
return await readStream(stream, callback, endCallback)
|
|
237
237
|
} catch (err) {
|
|
238
|
-
throw ioError(err, path, 'read')
|
|
238
|
+
throw this.ioError(err, path, 'read')
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
|
package/drivers/s3/index.js
CHANGED
|
@@ -147,7 +147,7 @@ class StorageClient {
|
|
|
147
147
|
return (err instanceof MobilettoError || err instanceof MobilettoNotFoundError)
|
|
148
148
|
? err
|
|
149
149
|
: (err instanceof NoSuchKey) || (err.name && err.name === 'NotFound')
|
|
150
|
-
? new MobilettoNotFoundError(key)
|
|
150
|
+
? new MobilettoNotFoundError(this.denormalizeKey(key))
|
|
151
151
|
: new MobilettoError(`${method}(${path}) error: ${err}`, err)
|
|
152
152
|
}
|
|
153
153
|
|