Skip to content
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

fix: getDatabaseBackups() should check error on .downloads deletion #6133

Merged
merged 1 commit into from May 10, 2024

Conversation

rfay
Copy link
Member

@rfay rfay commented Apr 26, 2024

The Issue

From https://discord.com/channels/664580571770388500/1232668554550186024/1232668554550186024

The .ddev/.downloads/files directory may exist somehow when trying to just get databases.

Currently in HEAD ddev pull ignores failure to delete and recreate the .downloads directory.

How This PR Solves The Issue

Check the error.

Manual Testing Instructions

Automated Testing Overview

Related Issue Link(s)

Release/Deployment Notes

@rfay rfay changed the title fix: getDatabaseBackups should check error on .downloads deletion fix: getDatabaseBackups() should check error on .downloads deletion Apr 26, 2024
@rfay rfay marked this pull request as ready for review April 29, 2024 14:12
@rfay rfay requested a review from a team as a code owner April 29, 2024 14:12
@rfay rfay requested a review from stasadev April 29, 2024 14:12
Copy link
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

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

GetBackup() has a call to prepDownloadDir():

func (p *Provider) GetBackup(backupType string) ([]string, []string, error) {
var err error
var fileNames []string
if backupType != "database" && backupType != "files" {
return nil, nil, fmt.Errorf("could not get backup: %s is not a valid backup type", backupType)
}
p.prepDownloadDir()

And prepDownloadDir() recreates files directory:

// prepDownloadDir ensures the download cache directories are created and writeable.
func (p *Provider) prepDownloadDir() {
destDir := p.getDownloadDir()
filesDir := filepath.Join(destDir, "files")
_ = os.RemoveAll(destDir)
err := os.MkdirAll(filesDir, 0755)
util.CheckErr(err)
}

The .ddev/.downloads/files directory may exist somehow when trying to just get databases.

prepDownloadDir() does not check the type of backup (from backupType) and always creates files.

Copy link
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

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

Hmm, I looked at the code again, and the .ddev/.downloads (or .ddev/.downloads/files) directory is deleted and then created again later.

But in any case, if files dir is created all the time before call to getDatabaseBackups(), then if the next command fails, it will remain, the check added here is correct.

@rfay
Copy link
Member Author

rfay commented Apr 30, 2024

But in any case, if files dir is created all the time before call to getDatabaseBackups(), then if the next command fails, it will remain, the check added here is correct.

Agreed.

The support issue in Discord appears to be something going wrong with mutagen or mutagen configuration. Even though mutagen sync is done, the files directory still exists.

@rfay rfay force-pushed the 20240426_check_pull_files_deletion branch from 0faf7cf to f028a22 Compare May 2, 2024 19:25
@rfay rfay merged commit 1dd85a6 into ddev:master May 10, 2024
17 of 18 checks passed
@rfay rfay deleted the 20240426_check_pull_files_deletion branch May 10, 2024 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants