Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 17, 2025

  • Explored repository structure and understood the issue
  • Located the problematic code in AbstractFileDownloadStrategy#symlink_location
  • Identified the issue: symlinks use "#{name}--#{version}#{ext}" which can be too long for casks with long URLs and versions
  • Found the suggested solution in issue comments: override download_name in Cask::Download
  • Verified current tests pass and typecheck is clean
  • Updated: Make download_name override conditional - only use cask token when URL-based symlink would exceed 255 characters
  • Refactored: Use super instead of duplicating parent class logic (File.basename(determine_url.to_s))
  • Further refactored: Use actual symlink_location method to calculate potential symlink length instead of duplicating symlink creation logic
  • Add comprehensive tests to verify the conditional behavior
  • Verified the change handles both short and long cases appropriately
  • Ensure the change handles edge cases and maintains backward compatibility
  • Run tests and typecheck to ensure no regressions

Updated Solution Summary

The fix now conditionally overrides the download_name method in Cask::Download:

  1. Calls super to get the URL basename from the parent class instead of duplicating logic
  2. Creates temporary download strategy with the URL basename to test actual symlink length using symlink_location method
  3. Only if that symlink length would exceed 255 characters, falls back to using cask.full_token.gsub("/", "--")
  4. Otherwise returns the parent class result

Code improvements:

  • Uses super instead of File.basename(determine_url.to_s) to avoid duplicating existing logic
  • Uses actual symlink_location method instead of duplicating symlink creation logic
  • Properly accounts for Utils.safe_filename processing that happens in the real symlink creation
  • Cleaner, more maintainable code that properly delegates to existing methods

Examples:

  • Short case: app.dmg--1.0.0.dmg (18 chars) → Uses parent class result (URL basename) ✅
  • Long case: actual qqmusic case (356 chars) → Uses cask token fallback qqmusic--... (179 chars) ✅

This preserves existing behavior for normal cases while fixing the filesystem limit issue for problematic URLs, and now properly uses existing methods instead of duplicating logic.

Fixes #20678.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Downloaded Cask asset symlink creation can error due to length Fix Cask download symlink creation errors due to long filenames Sep 17, 2025
@Copilot Copilot AI requested a review from MikeMcQuaid September 17, 2025 16:50
@Copilot Copilot AI requested a review from MikeMcQuaid September 18, 2025 08:57
Copilot finished work on behalf of MikeMcQuaid September 18, 2025 08:57
@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review September 19, 2025 07:17
Copy link
Member

@samford samford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just some small things, otherwise this makes sense to me. I can push a commit with these changes if that makes things easier.

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Sep 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 22, 2025
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Sep 22, 2025
Merged via the queue into main with commit 64fc6d3 Sep 22, 2025
42 of 44 checks passed
@MikeMcQuaid MikeMcQuaid deleted the copilot/fix-20678 branch September 22, 2025 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Downloaded Cask asset symlink creation can error due to length
3 participants