Skip to content

updater: stage update artifacts in temporary directory instead of workdir#8302

Open
foxly-it wants to merge 2 commits intoAdguardTeam:masterfrom
foxly-it:updater-temp-staging
Open

updater: stage update artifacts in temporary directory instead of workdir#8302
foxly-it wants to merge 2 commits intoAdguardTeam:masterfrom
foxly-it:updater-temp-staging

Conversation

@foxly-it
Copy link

Problem

The updater currently stages update artifacts inside the configured working
directory (workDir).

On embedded systems (for example ARM devices, routers or minimal VPS setups)
this can lead to update failures when the working directory resides on a
constrained filesystem.

Solution

This PR stages update artifacts in a dedicated temporary directory created
via os.MkdirTemp().

The rest of the update workflow remains unchanged.

Benefits

  • avoids writing large update files into installation directories
  • improves updater reliability on embedded / constrained systems
  • minimal change to existing updater logic

Related issue

#8086

Copy link

@windsurf-bot windsurf-bot bot left a comment

Choose a reason for hiding this comment

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

💡 To request another review, post a new comment with "/windsurf-review".

Comment on lines +226 to +229
u.tempDir, err = os.MkdirTemp("", "agh-update-*")
if err != nil {
return fmt.Errorf("creating temporary update dir: %w", err)
}
Copy link

Choose a reason for hiding this comment

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

The tempDir is created but never cleaned up if prepare() returns an error after creating the temporary directory. Consider adding a defer cleanup in the prepare() function to ensure the temporary directory is removed if any subsequent steps fail.

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, thanks.

I added cleanup for the temporary directory if prepare() returns an error
after os.MkdirTemp() succeeds.

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.

1 participant