mobiletto 1.0.14 → 1.0.17

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.
@@ -127,7 +127,8 @@ class StorageClient {
127
127
  if (recursive && objectCount === 0 && path !== '') {
128
128
  throw new MobilettoNotFoundError(path)
129
129
  }
130
- return objects
130
+ const filtered = objects.filter(o => o.name !== path)
131
+ return filtered
131
132
  }
132
133
 
133
134
  normalizeKey = (path) => {
package/index.js CHANGED
@@ -67,6 +67,28 @@ const UTILITY_FUNCTIONS = {
67
67
  }
68
68
  return await client.driver_list(path, recursive, visitor)
69
69
  },
70
+ safeList: (client) => async (path, opts) => {
71
+ const recursive = opts && opts.recursive ? opts.recursive : false
72
+ const visitor = opts && opts.visitor ? opts.visitor : null
73
+ try {
74
+ return await client.driver_list(path, recursive, visitor)
75
+ } catch (e) {
76
+ if (e instanceof MobilettoNotFoundError) {
77
+ return []
78
+ }
79
+ throw e
80
+ }
81
+ },
82
+ safeMetadata: (client) => async (path) => {
83
+ try {
84
+ return await client.driver_metadata(path)
85
+ } catch (e) {
86
+ if (e instanceof MobilettoNotFoundError) {
87
+ return null
88
+ }
89
+ throw e
90
+ }
91
+ },
70
92
  remove: (client) => async (path, opts) => {
71
93
  const recursive = opts && opts.recursive ? opts.recursive : false
72
94
  const quiet = opts && opts.quiet ? opts.quiet : false
@@ -91,6 +113,7 @@ const UTILITY_FUNCTIONS = {
91
113
  if (obj.type && obj.type === M_FILE) {
92
114
  logger.verbose(`mirror: mirroring file: ${obj.name}`)
93
115
  const tempPath = `${MOBILETTO_TMP}/mobiletto_${shasum(JSON.stringify(obj))}.${randomstring.generate(10)}`
116
+ logger.debug(`mirror: writing ${obj.name} to temp file ${tempPath} ...`)
94
117
  try {
95
118
  // write from source -> write to temp file
96
119
  const fd = fs.openSync(tempPath, 'wx', 0o0600)
@@ -100,6 +123,7 @@ const UTILITY_FUNCTIONS = {
100
123
  }, () => {
101
124
  writer.close((err) => {
102
125
  if (err) { throw new MobilettoError(`mirror: error closing temp file: ${err}`) }
126
+ logger.debug(`mirror: finished writing ${obj.name} to temp file ${tempPath}`)
103
127
  })
104
128
  }).then(async () => {
105
129
  // read from temp file -> write to mirror
@@ -108,7 +132,9 @@ const UTILITY_FUNCTIONS = {
108
132
  const destName = obj.name.startsWith(sourcePath)
109
133
  ? obj.name.substring(sourcePath.length)
110
134
  : obj.name
135
+ logger.debug(`mirror: writing temp file ${tempPath} to destination: ${clientPath + destName}`)
111
136
  await client.write(clientPath + destName, reader)
137
+ logger.debug(`mirror: finished writing temp file ${tempPath} to destination: ${clientPath + destName}`)
112
138
  })
113
139
  results.success++
114
140
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiletto",
3
- "version": "1.0.14",
3
+ "version": "1.0.17",
4
4
  "description": "A storage abstraction layer",
5
5
  "main": "index.js",
6
6
  "author": "Jonathan Cobb",