fixed "mozilla-release/obj-x86_64-pc-linux-gnu/dist/bin/browser/chrome/browser/content/browser/preferences/dialogs/addEngine.js" does not exist bug related to replace-all, I dont even want to know why is it doing that, jesus christ
This commit is contained in:
parent
3d08b492ac
commit
ffa413fe3c
2 changed files with 31 additions and 15 deletions
27
main.go
27
main.go
|
@ -147,18 +147,25 @@ func applyPatch(patchPath, rootPath string) error {
|
||||||
return fmt.Errorf("failed to read patch file: %v", err)
|
return fmt.Errorf("failed to read patch file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if inputFilePath == "" && patchType != "new" {
|
if patchType != "replace-all" {
|
||||||
return fmt.Errorf("patch file must specify input (i:) file")
|
if inputFilePath == "" && patchType != "new" {
|
||||||
}
|
return fmt.Errorf("patch file must specify input (i:) file")
|
||||||
|
}
|
||||||
|
|
||||||
if outputFilePath == "" {
|
if outputFilePath == "" {
|
||||||
return fmt.Errorf("patch file must specify output (o:) file")
|
return fmt.Errorf("patch file must specify output (o:) file")
|
||||||
}
|
}
|
||||||
|
|
||||||
if patchType != "new" && patchType != "copy" && inputFilePath != outputFilePath {
|
// Only do this rename if it's not 'new' or 'copy'
|
||||||
err = os.Rename(inputFilePath, outputFilePath)
|
if patchType != "new" && patchType != "copy" && inputFilePath != outputFilePath {
|
||||||
if err != nil {
|
// Only rename if the input file actually exists
|
||||||
return fmt.Errorf("failed to replace output file: %v", err)
|
if _, err := os.Stat(inputFilePath); os.IsNotExist(err) {
|
||||||
|
return fmt.Errorf("input file does not exist: %s", inputFilePath)
|
||||||
|
}
|
||||||
|
err = os.Rename(inputFilePath, outputFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to replace output file: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,24 @@ func applyReplaceAllPatch(rootPath string, modifications []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if d.IsDir() {
|
|
||||||
// Skip patcher's own directory and subdirectories
|
// Skip patcher's own dir and subdirs
|
||||||
if strings.HasPrefix(path, patcherDir) {
|
if strings.HasPrefix(path, patcherDir) {
|
||||||
|
if d.IsDir() {
|
||||||
return fs.SkipDir
|
return fs.SkipDir
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Skip patcher's own files
|
|
||||||
if strings.HasPrefix(path, patcherDir) {
|
// Skip any obj-* folders inside mozilla-release
|
||||||
|
if strings.Contains(path, "mozilla-release/obj-") {
|
||||||
|
if d.IsDir() {
|
||||||
|
return fs.SkipDir
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue