Skip to content

Commit

Permalink
Update version to v1.4.119 and commit
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 7, 2024
1 parent fbd6083 commit 2d8b46b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 49 deletions.
43 changes: 21 additions & 22 deletions common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,62 +12,61 @@ import (
// GetAbsolutePath resolves a given path to its absolute form, handling ~, ./, ../, UNC paths, and symlinks.
func GetAbsolutePath(path string) (string, error) {
if path == "" {
return "", errors.New("path is empty")
return "", errors.New("path is empty")
}

// Handle UNC paths on Windows
if runtime.GOOS == "windows" && strings.HasPrefix(path, `\\`) {
return path, nil
return path, nil
}

// Handle ~ for home directory expansion
if strings.HasPrefix(path, "~") {
home, err := os.UserHomeDir()
if err != nil {
return "", errors.New("could not resolve home directory")
}
path = filepath.Join(home, path[1:])
home, err := os.UserHomeDir()
if err != nil {
return "", errors.New("could not resolve home directory")
}
path = filepath.Join(home, path[1:])
}

// Convert to absolute path
absPath, err := filepath.Abs(path)
if err != nil {
return "", errors.New("could not get absolute path")
return "", errors.New("could not get absolute path")
}

// Resolve symlinks, but allow non-existent paths
resolvedPath, err := filepath.EvalSymlinks(absPath)
if err == nil {
return resolvedPath, nil
return resolvedPath, nil
}
if os.IsNotExist(err) {
// Return the absolute path for non-existent paths
return absPath, nil
// Return the absolute path for non-existent paths
return absPath, nil
}

return "", fmt.Errorf("could not resolve symlinks: %w", err)
}


// Helper function to check if a symlink points to a directory
func IsSymlinkToDir(path string) bool {
fileInfo, err := os.Lstat(path)
if err != nil {
return false
return false
}

if fileInfo.Mode()&os.ModeSymlink != 0 {
resolvedPath, err := filepath.EvalSymlinks(path)
if err != nil {
return false
}
resolvedPath, err := filepath.EvalSymlinks(path)
if err != nil {
return false
}

fileInfo, err = os.Stat(resolvedPath)
if err != nil {
return false
}
fileInfo, err = os.Stat(resolvedPath)
if err != nil {
return false
}

return fileInfo.IsDir()
return fileInfo.IsDir()
}

return false // Regular directories should not be treated as symlinks
Expand Down
2 changes: 1 addition & 1 deletion pkgs/fabric/version.nix
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"1.4.118"
"1.4.119"
1 change: 0 additions & 1 deletion plugins/db/fsdb/patterns.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func (o *PatternsEntity) GetApplyVariables(
return
}


func (o *PatternsEntity) applyVariables(
pattern *Pattern, variables map[string]string, input string) (err error) {

Expand Down
46 changes: 22 additions & 24 deletions plugins/db/fsdb/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,43 @@ func (o *StorageEntity) GetNames() (ret []string, err error) {
// Resolve the directory path to an absolute path
absDir, err := common.GetAbsolutePath(o.Dir)
if err != nil {
return nil, fmt.Errorf("could not resolve directory path: %v", err)
return nil, fmt.Errorf("could not resolve directory path: %v", err)
}

// Read the directory entries
var entries []os.DirEntry
if entries, err = os.ReadDir(absDir); err != nil {
return nil, fmt.Errorf("could not read items from directory: %v", err)
return nil, fmt.Errorf("could not read items from directory: %v", err)
}

for _, entry := range entries {
entryPath := filepath.Join(absDir, entry.Name())

// Get metadata for the entry, including symlink info
fileInfo, err := os.Lstat(entryPath)
if err != nil {
return nil, fmt.Errorf("could not stat entry %s: %v", entryPath, err)
entryPath := filepath.Join(absDir, entry.Name())

// Get metadata for the entry, including symlink info
fileInfo, err := os.Lstat(entryPath)
if err != nil {
return nil, fmt.Errorf("could not stat entry %s: %v", entryPath, err)
}

// Determine if the entry should be included
if o.ItemIsDir {
// Include directories or symlinks to directories
if fileInfo.IsDir() || (fileInfo.Mode()&os.ModeSymlink != 0 && common.IsSymlinkToDir(entryPath)) {
ret = append(ret, entry.Name())
}

// Determine if the entry should be included
if o.ItemIsDir {
// Include directories or symlinks to directories
if fileInfo.IsDir() || (fileInfo.Mode()&os.ModeSymlink != 0 && common.IsSymlinkToDir(entryPath)) {
ret = append(ret, entry.Name())
}
} else {
// Include files, optionally filtering by extension
if !fileInfo.IsDir() {
if o.FileExtension == "" || filepath.Ext(entry.Name()) == o.FileExtension {
ret = append(ret, strings.TrimSuffix(entry.Name(), o.FileExtension))
}
}
} else {
// Include files, optionally filtering by extension
if !fileInfo.IsDir() {
if o.FileExtension == "" || filepath.Ext(entry.Name()) == o.FileExtension {
ret = append(ret, strings.TrimSuffix(entry.Name(), o.FileExtension))
}
}
}
}

return ret, nil
}



func (o *StorageEntity) Delete(name string) (err error) {
if err = os.Remove(o.BuildFilePathByName(name)); err != nil {
err = fmt.Errorf("could not delete %s: %v", name, err)
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

var version = "v1.4.118"
var version = "v1.4.119"

0 comments on commit 2d8b46b

Please sign in to comment.