Skip to content

Commit 7b51ec5

Browse files
committed
fix(dest): correct collection handling
* do not create the collection for every file, only if it does not exist yet * proceed to next file by correctly calling the callback after creating collection in storeFile
1 parent 7ba8b6d commit 7b51ec5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ function sendFilesWith (client) {
8080
}
8181

8282
if (vf.isDirectory()) {
83-
return createCollection(client, normalizePath(conf.target + '/' + vf.relative), callback)
83+
return createCollection(client, normalizePath(conf.target + '/' + vf.relative))
84+
.then(function (result) {
85+
callback()
86+
})
8487
}
8588

8689
if (vf.isNull()) {
@@ -100,9 +103,12 @@ function sendFilesWith (client) {
100103
var collection = Path.normalize(conf.target) + '/' + folder
101104

102105
// create target collection if neccessary
103-
return createCollection(client, collection)
106+
return client.collections.describe(collection)
107+
.then(null, function () {
108+
return createCollection(client, collection)
109+
})
104110

105-
// upload file
111+
// then upload file
106112
.then(function (result) {
107113
gutil.log('Storing "' + file.base + file.relative + '" as (' + mime.lookup(file.path) + ')...')
108114
return client.documents.upload(file.contents)

0 commit comments

Comments
 (0)