Skip to content

Commit

Permalink
o/snapstate: export IconInstallFilename
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Calder <[email protected]>
  • Loading branch information
olivercalder committed Feb 5, 2025
1 parent baa3944 commit 0cd5115
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion overlord/snapstate/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ type DisabledServices = disabledServices
// snap icon helpers
var (
IconDownloadFilename = iconDownloadFilename
IconInstallFilename = iconInstallFilename
LinkSnapIcon = linkSnapIcon
UnlinkSnapIcon = unlinkSnapIcon
DiscardSnapIcon = discardSnapIcon
Expand Down
8 changes: 4 additions & 4 deletions overlord/snapstate/icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func iconDownloadFilename(snapID string) string {
return filepath.Join(dirs.SnapIconsPoolDir, fmt.Sprintf("%s.icon", snapID))
}

// iconInstallFilename returns the filepath of the icon in the icons directory
// IconInstallFilename returns the filepath of the icon in the icons directory
// for the given snap ID. This is where the icon should be hard-linked from the
// iconDownloadFilename when the snap is installed on the system.
func iconInstallFilename(snapID string) string {
func IconInstallFilename(snapID string) string {
if snapID == "" {
return ""
}
Expand All @@ -60,7 +60,7 @@ func linkSnapIcon(snapID string) error {
}

poolPath := iconDownloadFilename(snapID)
installPath := iconInstallFilename(snapID)
installPath := IconInstallFilename(snapID)

if !osutil.FileExists(poolPath) {
return fmt.Errorf("cannot link snap icon for snap %s: icon does not exist in the icons pool", snapID)
Expand All @@ -78,7 +78,7 @@ func unlinkSnapIcon(snapID string) error {
if snapID == "" {
return nil
}
if err := os.Remove(iconInstallFilename(snapID)); err != nil && !errors.Is(err, fs.ErrNotExist) {
if err := os.Remove(IconInstallFilename(snapID)); err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("cannot unlink snap icon for snap %s: %w", snapID, err)
}
return nil
Expand Down

0 comments on commit 0cd5115

Please sign in to comment.