Skip to content

Commit

Permalink
Added logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodecleyre committed Sep 2, 2023
1 parent 6f77d26 commit f8f99cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/m365/spo/commands/file/file-rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SpoFileRenameCommand extends SpoCommand {
await this.getFile(originalFileServerRelativePath, webUrl);

if (args.options.force) {
await this.deleteFile(webUrl, args.options.sourceUrl, args.options.targetFileName);
await this.deleteFile(webUrl, args.options.sourceUrl, args.options.targetFileName, logger);
}

const requestBody: any = {
Expand Down Expand Up @@ -131,11 +131,11 @@ class SpoFileRenameCommand extends SpoCommand {
return request.get(requestOptions);
}

private async deleteFile(webUrl: string, sourceUrl: string, targetFileName: string): Promise<void> {
private async deleteFile(webUrl: string, sourceUrl: string, targetFileName: string, logger: Logger): Promise<void> {
const targetFileServerRelativeUrl: string = `${urlUtil.getServerRelativePath(webUrl, sourceUrl.substring(0, sourceUrl.lastIndexOf('/')))}/${targetFileName}`;

try {
await spo.removeFile(webUrl, targetFileServerRelativeUrl, true);
await spo.removeFile(webUrl, targetFileServerRelativeUrl, true, logger, this.verbose);
}
catch (err: any) {
if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/spo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1454,11 +1454,12 @@ export const spo = {

return webProperties;
},

/**
* removes a file by url
* @param webUrl The web url
* @param url The url of the file
* @param url If file should be recycled or not
* @param recycle If file should be recycled or not
* @param logger The logger object
* @param verbose Set for verbose logging
*/
Expand Down

0 comments on commit f8f99cd

Please sign in to comment.