Skip to content

Commit

Permalink
fix: Adding warnings, if asset download tries overwriting an existing…
Browse files Browse the repository at this point in the history
… file
  • Loading branch information
steilerDev committed Oct 1, 2023
1 parent 8adbb13 commit 10c60b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 0 additions & 2 deletions app/src/lib/resources/events-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export enum iCPSEventRuntimeWarning {
* Emitted, if an iCloud asset could not be loaded - provides the error, asset and master object as arguments
*/
ICLOUD_LOAD_ERROR = `warn-icloud_load_error`,

/**
* Emitted when the write process has experienced an error while verifying a written asset - provides the error and asset as argument
*/
Expand All @@ -136,7 +135,6 @@ export enum iCPSEventRuntimeWarning {
* Emitted when an asset cannot be linked to an album - provides the error, src and destination path as arguments
*/
LINK_ERROR = `warn-link_error`,

/**
* Emitted when a filetype is unknown to the script - provides the extension and descriptor as arguments (if available)
*/
Expand Down
10 changes: 10 additions & 0 deletions app/src/lib/resources/network-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,16 @@ export class NetworkManager {
*/
async downloadData(url: string, location: string): Promise<void> {
await this._streamingCCYLimiter.add(async () => {

const fileExists = await fs.stat(location)
.then((stat) => stat.isFile())
.catch(() => false)

if (fileExists) {
Resources.logger(this).warn(`Skipping download of ${url} to ${location} as file already exists`);
return;
}

Resources.logger(this).debug(`Starting download of ${url}`);
const response = await this._streamingAxios.get(url);
Resources.logger(this).debug(`Starting to write ${url} to ${location}`);
Expand Down

0 comments on commit 10c60b6

Please sign in to comment.