diff --git a/scripts.v2/utils.js b/scripts.v2/utils.js index 42a08bbf3..6c54c4529 100644 --- a/scripts.v2/utils.js +++ b/scripts.v2/utils.js @@ -140,23 +140,24 @@ async function downloadBlobsRecursive(containerClient, outputFolder, prefix = un let blobs = containerClient.listBlobsByHierarchy("/", prefix ? { prefix: prefix } : undefined); for await (const blob of blobs) { if (blob.kind === "prefix") { - await this.downloadBlobsRecursive(containerClient, outputFolder, blob.name); - } else { - const blockBlobClient = containerClient.getBlockBlobClient(blob.name); - const extension = mime.getExtension(blob.properties.contentType); - let pathToFile; + await downloadBlobsRecursive(containerClient, outputFolder, blob.name); + continue; + } - if (extension != null) { - pathToFile = `${snapshotMediaFolder}/${blob.name}.${extension}`; - } - else { - pathToFile = `${snapshotMediaFolder}/${blob.name}`; - } + const blockBlobClient = containerClient.getBlockBlobClient(blob.name); + const extension = mime.getExtension(blob.properties.contentType); + let pathToFile; - const folderPath = pathToFile.substring(0, pathToFile.lastIndexOf("/")); - await fs.promises.mkdir(path.resolve(folderPath), { recursive: true }); - await blockBlobClient.downloadToFile(pathToFile); + if (extension != null) { + pathToFile = `${outputFolder}/${blob.name}.${extension}`; + } + else { + pathToFile = `${outputFolder}/${blob.name}`; } + + const folderPath = pathToFile.substring(0, pathToFile.lastIndexOf("/")); + await fs.promises.mkdir(path.resolve(folderPath), { recursive: true }); + await blockBlobClient.downloadToFile(pathToFile); } } diff --git a/scripts.v3/utils.js b/scripts.v3/utils.js index cc721a381..83302eb36 100644 --- a/scripts.v3/utils.js +++ b/scripts.v3/utils.js @@ -255,18 +255,19 @@ class ImporterExporter { for await (const blob of blobs) { if (blob.kind === "prefix") { await this.downloadBlobsRecursive(containerClient, outputFolder, blob.name); - } else { - const blockBlobClient = containerClient.getBlockBlobClient(blob.name); - const pathToFile = `${outputFolder}/${blob.name}`; - const folderPath = pathToFile.substring(0, pathToFile.lastIndexOf("/")); + continue; + } - await fs.promises.mkdir(path.resolve(folderPath), { recursive: true }); - await blockBlobClient.downloadToFile(pathToFile); + const blockBlobClient = containerClient.getBlockBlobClient(blob.name); + const pathToFile = `${outputFolder}/${blob.name}`; + const folderPath = pathToFile.substring(0, pathToFile.lastIndexOf("/")); - const metadata = { contentType: blob.properties.contentType }; - const metadataFile = JSON.stringify(metadata); - await fs.promises.writeFile(pathToFile + metadataFileExt, metadataFile); - } + await fs.promises.mkdir(path.resolve(folderPath), { recursive: true }); + await blockBlobClient.downloadToFile(pathToFile); + + const metadata = { contentType: blob.properties.contentType }; + const metadataFile = JSON.stringify(metadata); + await fs.promises.writeFile(pathToFile + metadataFileExt, metadataFile); } }