-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix ArchiveFilesV2 task to properly handle adding single files to existing archives #21036
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
base: master
Are you sure you want to change the base?
Conversation
…chives Co-authored-by: ivanduplenskikh <115665590+ivanduplenskikh@users.noreply.github.com>
Tasks/ArchiveFilesV2/archivefiles.ts
Outdated
for (var i = 0; i < fullPaths.length; i++) { | ||
baseNames[i] = path.basename(fullPaths[i]); | ||
// Check if rootFolderOrFile is a file | ||
if (fs.existsSync(rootFolderOrFile) && fs.statSync(rootFolderOrFile).isFile()) { |
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.
@copilot, could you please add an additional check there with the feature flag DistributedTasks.Task.ArchiveOneFileWithRootFolderInput
to ensure it is executed only when this flag is enabled by using tl.getPipelineFeature
?
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've added the feature flag check as requested. The single file handling in the findFiles()
function now only works when the DistributedTasks.Task.ArchiveOneFileWithRootFolderInput
feature flag is enabled. When the flag is disabled, it falls back to the original behavior. Changes are in commit 481a343.
Co-authored-by: ivanduplenskikh <115665590+ivanduplenskikh@users.noreply.github.com>
Good afternoon, Is the fix for this going to happen soon? We have dependencies for this due to the build pipelines failing. |
@Driver-glitch just do this: - - task: ArchiveFiles@2
+ - task: ArchiveFiles@2.254.1 |
I am not using YAML. Any workaround in that case? |
I wound workaround. Selecting "Prepend root folder name to archive paths" fixes the issue. This flag does not have any influence on my archive, so good enough. |
Issue
When using the ArchiveFilesV2 task with
rootFolderOrFile
pointing to a single file andincludeRootFolder: false
, adding to an existing archive (replaceExistingArchive: false
) fails with a "Nothing to do" error.Root Cause
The
findFiles()
function was not correctly handling the case whenincludeRootFolder
is false androotFolderOrFile
points to a single file. The function was usingtl.ls()
, which is designed to list directory contents but doesn't handle file paths properly.Fix
Added a check in the
findFiles()
function to determine ifrootFolderOrFile
is a file whenincludeRootFolder
is false. If it is a file, the function now returns the basename of the file directly, matching the behavior whenincludeRootFolder
is true.Testing
Added a new test case
Successfully adds a single file to an existing archive
that verifies the task can properly add a single file to an existing archive.Fixes #21033.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
cdn.fwupd.org
/usr/bin/fwupdmgr refresh
(dns block)pkgs.dev.azure.com
npm install
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.