forked from Plemya-x/ALR
		
	fix: add config load and directory creation
This commit is contained in:
		| @@ -11,7 +11,7 @@ | |||||||
|     <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |     <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> | ||||||
|         <text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> |         <text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> | ||||||
|         <text x="33.5" y="14">coverage</text> |         <text x="33.5" y="14">coverage</text> | ||||||
|         <text x="86" y="15" fill="#010101" fill-opacity=".3">19.5%</text> |         <text x="86" y="15" fill="#010101" fill-opacity=".3">19.4%</text> | ||||||
|         <text x="86" y="14">19.5%</text> |         <text x="86" y="14">19.4%</text> | ||||||
|     </g> |     </g> | ||||||
| </svg> | </svg> | ||||||
|   | |||||||
| Before Width: | Height: | Size: 926 B After Width: | Height: | Size: 926 B | 
| @@ -12,7 +12,7 @@ | |||||||
|     <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |     <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> | ||||||
|         <text x="37" y="15" fill="#010101" fill-opacity=".3">ru translate</text> |         <text x="37" y="15" fill="#010101" fill-opacity=".3">ru translate</text> | ||||||
|         <text x="37" y="14">ru translate</text> |         <text x="37" y="14">ru translate</text> | ||||||
|         <text x="100" y="15" fill="#010101" fill-opacity=".3">98.00%</text> |         <text x="100" y="15" fill="#010101" fill-opacity=".3">97.00%</text> | ||||||
|         <text x="100" y="14">98.00%</text> |         <text x="100" y="14">97.00%</text> | ||||||
|     </g> |     </g> | ||||||
| </svg> | </svg> | ||||||
|   | |||||||
| Before Width: | Height: | Size: 940 B After Width: | Height: | Size: 940 B | 
| @@ -171,7 +171,13 @@ func (c *ALRConfig) GetPaths() *Paths { | |||||||
| } | } | ||||||
|  |  | ||||||
| func (c *ALRConfig) initPaths() { | func (c *ALRConfig) initPaths() { | ||||||
| 	err := os.MkdirAll(c.paths.RepoDir, 0o755) | 	err := os.MkdirAll(filepath.Dir(c.paths.UserConfigPath), 0o755) | ||||||
|  | 	if err != nil { | ||||||
|  | 		slog.Error(gotext.Get("Unable to create config directory"), "err", err) | ||||||
|  | 		os.Exit(1) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	err = os.MkdirAll(c.paths.RepoDir, 0o755) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		slog.Error(gotext.Get("Unable to create repo cache directory"), "err", err) | 		slog.Error(gotext.Get("Unable to create repo cache directory"), "err", err) | ||||||
| 		os.Exit(1) | 		os.Exit(1) | ||||||
|   | |||||||
| @@ -255,10 +255,14 @@ msgid "OPTIONS" | |||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: internal/config/config.go:176 | #: internal/config/config.go:176 | ||||||
| msgid "Unable to create repo cache directory" | msgid "Unable to create config directory" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: internal/config/config.go:182 | #: internal/config/config.go:182 | ||||||
|  | msgid "Unable to create repo cache directory" | ||||||
|  | msgstr "" | ||||||
|  |  | ||||||
|  | #: internal/config/config.go:188 | ||||||
| msgid "Unable to create package cache directory" | msgid "Unable to create package cache directory" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -449,7 +453,7 @@ msgstr "" | |||||||
| msgid "URL of the new repo" | msgid "URL of the new repo" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:86 repo.go:151 | #: repo.go:86 repo.go:156 | ||||||
| msgid "Error saving config" | msgid "Error saving config" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| @@ -461,19 +465,19 @@ msgstr "" | |||||||
| msgid "Name of the repo to be deleted" | msgid "Name of the repo to be deleted" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:137 | #: repo.go:142 | ||||||
| msgid "Repo does not exist" | msgid "Repo does not exist" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:145 | #: repo.go:150 | ||||||
| msgid "Error removing repo directory" | msgid "Error removing repo directory" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:162 | #: repo.go:167 | ||||||
| msgid "Error removing packages from database" | msgid "Error removing packages from database" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
| #: repo.go:174 | #: repo.go:179 | ||||||
| msgid "Pull all repositories that have changed" | msgid "Pull all repositories that have changed" | ||||||
| msgstr "" | msgstr "" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -263,10 +263,15 @@ msgid "OPTIONS" | |||||||
| msgstr "ПАРАМЕТРЫ" | msgstr "ПАРАМЕТРЫ" | ||||||
|  |  | ||||||
| #: internal/config/config.go:176 | #: internal/config/config.go:176 | ||||||
|  | #, fuzzy | ||||||
|  | msgid "Unable to create config directory" | ||||||
|  | msgstr "Не удалось создать каталог конфигурации ALR" | ||||||
|  |  | ||||||
|  | #: internal/config/config.go:182 | ||||||
| msgid "Unable to create repo cache directory" | msgid "Unable to create repo cache directory" | ||||||
| msgstr "Не удалось создать каталог кэша репозитория" | msgstr "Не удалось создать каталог кэша репозитория" | ||||||
|  |  | ||||||
| #: internal/config/config.go:182 | #: internal/config/config.go:188 | ||||||
| msgid "Unable to create package cache directory" | msgid "Unable to create package cache directory" | ||||||
| msgstr "Не удалось создать каталог кэша пакетов" | msgstr "Не удалось создать каталог кэша пакетов" | ||||||
|  |  | ||||||
| @@ -466,7 +471,7 @@ msgstr "Название нового репозитория" | |||||||
| msgid "URL of the new repo" | msgid "URL of the new repo" | ||||||
| msgstr "URL-адрес нового репозитория" | msgstr "URL-адрес нового репозитория" | ||||||
|  |  | ||||||
| #: repo.go:86 repo.go:151 | #: repo.go:86 repo.go:156 | ||||||
| #, fuzzy | #, fuzzy | ||||||
| msgid "Error saving config" | msgid "Error saving config" | ||||||
| msgstr "Ошибка при кодировании конфигурации" | msgstr "Ошибка при кодировании конфигурации" | ||||||
| @@ -479,19 +484,19 @@ msgstr "Удалить существующий репозиторий" | |||||||
| msgid "Name of the repo to be deleted" | msgid "Name of the repo to be deleted" | ||||||
| msgstr "Название репозитория  удалён" | msgstr "Название репозитория  удалён" | ||||||
|  |  | ||||||
| #: repo.go:137 | #: repo.go:142 | ||||||
| msgid "Repo does not exist" | msgid "Repo does not exist" | ||||||
| msgstr "Репозитория не существует" | msgstr "Репозитория не существует" | ||||||
|  |  | ||||||
| #: repo.go:145 | #: repo.go:150 | ||||||
| msgid "Error removing repo directory" | msgid "Error removing repo directory" | ||||||
| msgstr "Ошибка при удалении каталога репозитория" | msgstr "Ошибка при удалении каталога репозитория" | ||||||
|  |  | ||||||
| #: repo.go:162 | #: repo.go:167 | ||||||
| msgid "Error removing packages from database" | msgid "Error removing packages from database" | ||||||
| msgstr "Ошибка при удалении пакетов из базы данных" | msgstr "Ошибка при удалении пакетов из базы данных" | ||||||
|  |  | ||||||
| #: repo.go:174 | #: repo.go:179 | ||||||
| msgid "Pull all repositories that have changed" | msgid "Pull all repositories that have changed" | ||||||
| msgstr "Скачать все изменённые репозитории" | msgstr "Скачать все изменённые репозитории" | ||||||
|  |  | ||||||
| @@ -552,9 +557,6 @@ msgstr "Здесь нечего делать." | |||||||
| #~ msgid "Unable to detect user config directory" | #~ msgid "Unable to detect user config directory" | ||||||
| #~ msgstr "Не удалось обнаружить каталог конфигурации пользователя" | #~ msgstr "Не удалось обнаружить каталог конфигурации пользователя" | ||||||
|  |  | ||||||
| #~ msgid "Unable to create ALR config directory" |  | ||||||
| #~ msgstr "Не удалось создать каталог конфигурации ALR" |  | ||||||
|  |  | ||||||
| #~ msgid "Unable to create ALR config file" | #~ msgid "Unable to create ALR config file" | ||||||
| #~ msgstr "Не удалось создать конфигурационный файл ALR" | #~ msgstr "Не удалось создать конфигурационный файл ALR" | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								repo.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								repo.go
									
									
									
									
									
								
							| @@ -123,6 +123,11 @@ func RemoveRepoCmd() *cli.Command { | |||||||
|  |  | ||||||
| 			name := c.String("name") | 			name := c.String("name") | ||||||
| 			cfg := config.New() | 			cfg := config.New() | ||||||
|  | 			err := cfg.Load() | ||||||
|  | 			if err != nil { | ||||||
|  | 				slog.Error(gotext.Get("Error loading config"), "err", err) | ||||||
|  | 				os.Exit(1) | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			found := false | 			found := false | ||||||
| 			index := 0 | 			index := 0 | ||||||
| @@ -140,7 +145,7 @@ func RemoveRepoCmd() *cli.Command { | |||||||
|  |  | ||||||
| 			cfg.SetRepos(slices.Delete(reposSlice, index, index+1)) | 			cfg.SetRepos(slices.Delete(reposSlice, index, index+1)) | ||||||
|  |  | ||||||
| 			err := os.RemoveAll(filepath.Join(cfg.GetPaths().RepoDir, name)) | 			err = os.RemoveAll(filepath.Join(cfg.GetPaths().RepoDir, name)) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				slog.Error(gotext.Get("Error removing repo directory"), "err", err) | 				slog.Error(gotext.Get("Error removing repo directory"), "err", err) | ||||||
| 				os.Exit(1) | 				os.Exit(1) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user