-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JavaToolInstallerV0 ] Changed logic of extraction, fix inactivated Clean Destination Directory issue #13209
[JavaToolInstallerV0 ] Changed logic of extraction, fix inactivated Clean Destination Directory issue #13209
Conversation
162047e
to
790e3f6
Compare
790e3f6
to
70f6813
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the comments, other changes are LGTM, thanks!
sevenZip.arg(file); | ||
const execResult = sevenZip.execSync(); | ||
if (execResult.code != taskLib.TaskResult.Succeeded) { | ||
taskLib.debug('execResult: ' + JSON.stringify(execResult)); | ||
} | ||
} | ||
|
||
public static getFileEnding(file: string): string { | ||
let fileEnding = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a better way is to extract the file extension firstly and then check if it supported.
Also maybe better move array with the supported file extension as global constant?
const fileEnding = file.substring(file.lastIndexOf('.'));
const supportedFileExtension: Array<string> = ['.tar', '.tar.gz', '.zip', '.7z'];
if (!supportedFileEndings.some((extension) => extension === fileEnding)) {
throw new Error(taskLib.loc('UnsupportedFileExtension'));
}
return fileEnding;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexander-smolyakov the problem we saw here is that there's a validation for file ending - it differs from file extension... For example, for filename.tar.gz is considered to have file ending '.tar.gz', but '.gz' as extension. There's also could be the case when there's a dot in filename (like 'file.name.tar.gz'), so we can't simply extract substring after first dot...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anatolybolshakov Oh, I see now. I think it will be useful to add information about these cases in the function description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That function was just moved here from javatoolinstaller.ts
to avoid the circular dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it also makes sense to describe difference between file ending/file extension here - I asked @ekaterina-tatanova to update comments since she reworked this method also and added some js doc for it in another on-code-review PR - #13203 (comment)
@@ -179,4 +181,4 @@ | |||
"UsePreinstalledJava": "ms-resource:loc.messages.UsePreinstalledJava", | |||
"WrongArchiveStructure": "ms-resource:loc.messages.WrongArchiveStructure" | |||
} | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Add EOL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
0754de3
to
60fce3a
Compare
@@ -62,6 +63,8 @@ export class JavaFilesExtractor { | |||
const sevenZip = taskLib.tool(this.getSevenZipLocation()); | |||
sevenZip.arg('x'); | |||
sevenZip.arg('-o' + destinationFolder); | |||
// skip if exists | |||
sevenZip.arg('-aos'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this change of behavior break existing customers? Do we need to hide it behind an input flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. In order to keep the task working for existing customers, it's better to get rid of this line at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean if someone wants to use archives from cache they can just inactivate Clean Directory checkbox.
60fce3a
to
a1d811a
Compare
a1d811a
to
b1b10c8
Compare
Task name: JavaToolInstaller
Description:
Documentation changes required: (Y/N) Yes, #88
Added unit tests: (Y/N) No, will be done in #81
Attached related issue: (Y/N) https://github.com/microsoft/build-task-team/issues/10
Checklist:
Test Build Result: Build