From 2f14ce88cc3221863c9cacbb66a18ec7d499afd7 Mon Sep 17 00:00:00 2001 From: khalefa Date: Sat, 12 Oct 2024 12:45:54 +0300 Subject: [PATCH] fixed a bug where the filter will be lost if the file within a subfolder --- VERSION | 2 +- hfdownloader/hfdownloader.go | 9 +++++++-- main.go | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index e05cb33..d4c4950 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.8 +1.3.9 diff --git a/hfdownloader/hfdownloader.go b/hfdownloader/hfdownloader.go index 41406e6..5aacb3a 100644 --- a/hfdownloader/hfdownloader.go +++ b/hfdownloader/hfdownloader.go @@ -131,6 +131,7 @@ func processHFFolderTree(ModelPath string, IsDataset bool, SkipSHA bool, ModelDa AgreementURL := fmt.Sprintf(AgreementModelURL, ModelDatasetName) HasFilter := false var FilterBinFileString []string + originalDataSetName := ModelDatasetName // fix a bug where filters will be skipped when we call the function recursiley if strings.Contains(ModelDatasetName, ":") && !IsDataset { HasFilter = true // remove the filtered content from Model Name @@ -175,7 +176,9 @@ func processHFFolderTree(ModelPath string, IsDataset bool, SkipSHA bool, ModelDa if err := os.MkdirAll(filePath, os.ModePerm); err != nil { return err } - if err := processHFFolderTree(ModelPath, IsDataset, SkipSHA, ModelDatasetName, Branch, file.Path, silentMode); err != nil { + //here we should pass the original name with filters, other wise the filter will be applied + + if err := processHFFolderTree(ModelPath, IsDataset, SkipSHA, originalDataSetName, Branch, file.Path, silentMode); err != nil { return err } } else { @@ -256,7 +259,9 @@ func processHFFolderTree(ModelPath string, IsDataset bool, SkipSHA bool, ModelDa } jsonFilesList[i].SkipDownloading = true // now if this a folder, this whole function will be called again recursively - err = processHFFolderTree(ModelPath, IsDataset, SkipSHA, ModelDatasetName, Branch, jsonFilesList[i].Path, silentMode) // recursive call + //here we should pass the original name with filters, other wise the filter will be applied + + err = processHFFolderTree(ModelPath, IsDataset, SkipSHA, originalDataSetName, Branch, jsonFilesList[i].Path, silentMode) // recursive call if err != nil { return err } diff --git a/main.go b/main.go index fae595b..02e00a4 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/cobra" ) -const VERSION = "1.3.8" +const VERSION = "1.3.9" type Config struct { NumConnections int `json:"num_connections"`