artifact-engine
Advanced tools
Comparing version
"use strict"; | ||
const path = require('path'); | ||
var tl = require('vsts-task-lib/task'); | ||
var minimatch = require('minimatch'); | ||
const models = require('../Models'); | ||
@@ -117,4 +116,16 @@ const ci = require('./cilogger'); | ||
}); | ||
this.artifactItemStore.addItems(items); | ||
this.artifactItemStore.updateState(item, models.TicketState.Processed); | ||
if (items.length > 0) { | ||
this.artifactItemStore.addItems(items); | ||
this.artifactItemStore.updateState(item, models.TicketState.Processed); | ||
} | ||
else { | ||
destProvider.putArtifactItem(item, null) | ||
.then((item) => { | ||
this.artifactItemStore.updateState(item, models.TicketState.Processed); | ||
resolve(); | ||
}, (err) => { | ||
logger_1.Logger.logInfo("Error creating folder " + item.path + ": " + err); | ||
retryIfRequired(err); | ||
}); | ||
} | ||
logger_1.Logger.logInfo("Enqueued " + items.length + " for processing."); | ||
@@ -121,0 +132,0 @@ resolve(); |
{ | ||
"name": "artifact-engine", | ||
"version": "0.1.23", | ||
"version": "0.1.24", | ||
"description": "Artifact Engine to download artifacts from jenkins, teamcity, vsts", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -44,27 +44,38 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
const outputFilename = path.join(this._rootLocation, item.path); | ||
const folder = path.dirname(outputFilename); | ||
try { | ||
tl.mkdirP(folder); | ||
logger_1.Logger.logMessage(tl.loc("DownloadingTo", item.path, outputFilename)); | ||
const outputStream = fs.createWriteStream(outputFilename); | ||
stream.pipe(outputStream); | ||
stream.on("end", () => { | ||
logger_1.Logger.logMessage(tl.loc("DownloadedTo", item.path, outputFilename)); | ||
if (!item.metadata) { | ||
item.metadata = {}; | ||
} | ||
item.metadata[models.Constants.DestinationUrlKey] = outputFilename; | ||
}); | ||
stream.on("error", (error) => { | ||
reject(error); | ||
}); | ||
outputStream.on("finish", () => { | ||
this.artifactItemStore.updateFileSize(item, outputStream.bytesWritten); | ||
const outputItemPath = path.join(this._rootLocation, item.path); | ||
if (item.itemType === models.ItemType.File) { | ||
const folder = path.dirname(outputItemPath); | ||
try { | ||
tl.mkdirP(folder); | ||
logger_1.Logger.logMessage(tl.loc("DownloadingTo", item.path, outputItemPath)); | ||
const outputStream = fs.createWriteStream(outputItemPath); | ||
stream.pipe(outputStream); | ||
stream.on("end", () => { | ||
logger_1.Logger.logMessage(tl.loc("DownloadedTo", item.path, outputItemPath)); | ||
if (!item.metadata) { | ||
item.metadata = {}; | ||
} | ||
item.metadata[models.Constants.DestinationUrlKey] = outputItemPath; | ||
}); | ||
stream.on("error", (error) => { | ||
reject(error); | ||
}); | ||
outputStream.on("finish", () => { | ||
this.artifactItemStore.updateFileSize(item, outputStream.bytesWritten); | ||
resolve(item); | ||
}); | ||
} | ||
catch (err) { | ||
reject(err); | ||
} | ||
} | ||
else { | ||
try { | ||
tl.mkdirP(outputItemPath); | ||
resolve(item); | ||
}); | ||
} | ||
catch (err) { | ||
reject(err); | ||
} | ||
} | ||
catch (err) { | ||
reject(err); | ||
} | ||
}); | ||
@@ -71,0 +82,0 @@ } |
@@ -60,12 +60,17 @@ "use strict"; | ||
var data = ''; | ||
readStream.on('data', (chunk) => { | ||
data += chunk; | ||
}); | ||
readStream.on('end', () => { | ||
this.itemsUploaded[item.path] = data; | ||
if (item.itemType === models.ItemType.File) { | ||
readStream.on('data', (chunk) => { | ||
data += chunk; | ||
}); | ||
readStream.on('end', () => { | ||
this.itemsUploaded[item.path] = data; | ||
resolve(item); | ||
}); | ||
readStream.on('error', () => { | ||
reject(item); | ||
}); | ||
} | ||
else { | ||
resolve(item); | ||
}); | ||
readStream.on('error', () => { | ||
reject(item); | ||
}); | ||
} | ||
}); | ||
@@ -72,0 +77,0 @@ return promise; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
163343
1.49%84
1.2%2329
1.84%