Skip to content

Commit

Permalink
fix: help mutagen work with Drupal's read-only settings files, fixes d…
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay authored Oct 28, 2024
1 parent d575ecc commit ac97e92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/ddevapp/drupal.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path"
"path/filepath"
"strconv"
"strings"
"text/template"

"github.com/ddev/ddev/pkg/archive"
Expand Down Expand Up @@ -522,6 +523,23 @@ func drupalEnsureWritePerms(app *DdevApp) error {
util.Warning("Unable to set permissions: %v", err)
}
}
// It is possible that a Drupal install has been done, setting sites/default and sites/default/settings.php
// to read-only, which breaks mutagen's access to them so mutagen then
// can't sync. See https://github.com/ddev/ddev/issues/6491
// So we chmod +w the two files that a Drupal install may set read-only
// *inside* the container, allowing mutagen access to it again
if app.IsMutagenEnabled() {
settingsFiles := []string{
filepath.Join(app.Docroot, `sites/default`),
filepath.Join(app.Docroot, `sites/default/settings.php`),
}
_, stderr, err := app.Exec(&ExecOpts{
Cmd: fmt.Sprintf(`chmod -f u+w %s`, strings.Join(settingsFiles, " ")),
})
if err != nil {
util.Warning("Unable to set permissions inside container on settings files: '%s'", stderr)
}
}

return nil
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/ddevapp/mutagen.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,17 @@ func (app *DdevApp) MutagenStatus() (status string, shortResult string, mapResul
if _, ok = alpha["scanProblems"]; ok {
problems = true
}
if _, ok = alpha["transitionProblems"]; ok {
problems = true
}
}
if beta, ok := session["beta"].(map[string]interface{}); ok {
if _, ok = beta["scanProblems"]; ok {
problems = true
}
if _, ok = beta["transitionProblems"]; ok {
problems = true
}
}
if _, ok := session["conflicts"]; ok {
problems = true
Expand Down

0 comments on commit ac97e92

Please sign in to comment.