@@ -12,6 +12,7 @@ import (
1212 "strings"
1313 "time"
1414
15+ "github.com/adrg/xdg"
1516 "github.com/goccy/go-yaml"
1617 "github.com/urfave/cli/v3"
1718 "github.com/zeebo/errs"
@@ -31,6 +32,7 @@ type repository struct {
3132 URL string `yaml:"URL" description:"URL of the repository."`
3233 PubKeys map [string ]string `yaml:"pubKeys" description:"URLs to the public keys for signature verification."`
3334 SyncInterval time.Duration `yaml:"syncInterval" description:"Interval for syncing this repository."`
35+ FallbackURLs []string `yaml:"fallbackURLs,omitempty" description:"Fallback URLs for the repository."`
3436}
3537
3638type config struct {
@@ -80,11 +82,7 @@ func configCommand() *cli.Command {
8082 if c .Bool ("new" ) {
8183 configFilePath := os .Getenv ("DBIN_CONFIG_FILE" )
8284 if configFilePath == "" {
83- userConfigDir , err := os .UserConfigDir ()
84- if err != nil {
85- return errConfigFileAccess .Wrap (err )
86- }
87- configFilePath = filepath .Join (userConfigDir , "dbin" , "dbin.yaml" )
85+ configFilePath = filepath .Join (xdg .ConfigHome , "dbin" , "dbin.yaml" )
8886 }
8987 return createDefaultConfigAt (configFilePath )
9088 } else if c .Bool ("show" ) {
@@ -213,11 +211,7 @@ func loadConfig() (*config, error) {
213211
214212 configFilePath := os .Getenv ("DBIN_CONFIG_FILE" )
215213 if configFilePath == "" {
216- userConfigDir , err := os .UserConfigDir ()
217- if err != nil {
218- return nil , errConfigFileAccess .Wrap (err )
219- }
220- configFilePath = filepath .Join (userConfigDir , "dbin" , "dbin.yaml" )
214+ configFilePath = filepath .Join (xdg .ConfigHome , "dbin" , "dbin.yaml" )
221215 }
222216
223217 if _ , err := os .Stat (configFilePath ); os .IsNotExist (err ) {
@@ -231,10 +225,17 @@ func loadConfig() (*config, error) {
231225 }
232226
233227 for v := version - 0.1 ; v >= version - 0.3 ; v -= 0.1 {
234- url := fmt .Sprintf ("https://github.com/xplshn/dbin-metadata/raw/refs/heads/master/misc/cmd/%.1f/%s%s" , v , arch , ".nlite.cbor.zst" )
228+ main := fmt .Sprintf ("https://d.xplshn.com.ar/misc/cmd/%.1f/%s.nlite.cbor.zst" , v , arch )
229+ fallback := fmt .Sprintf ("https://github.com/xplshn/dbin-metadata/raw/refs/heads/master/misc/cmd/%.1f/%s.nlite.cbor.zst" , v , arch )
230+
235231 for _ , repo := range cfg .Repositories {
236- if repo .URL == url {
237- fmt .Printf ("Warning: Your config may be outdated. Your repoURL matches version: %.1f, but we're in version: %.1f\n " , v , version )
232+ if repo .URL == main {
233+ fmt .Printf ("Warning: One of your repository URLs points to version %.1f, which may be outdated. Current version is %.1f\n " , v , version )
234+ }
235+ for _ , fb := range repo .FallbackURLs {
236+ if fb == fallback {
237+ fmt .Printf ("Warning: One of your fallback URLs points to version %.1f, which may be outdated. Current version is %.1f\n " , v , version )
238+ }
238239 }
239240 }
240241 }
@@ -306,30 +307,17 @@ func overrideWithEnv(cfg *config) {
306307}
307308
308309func setDefaultValues (config * config ) {
309- homeDir , err := os .UserHomeDir ()
310- if err != nil {
311- fmt .Printf ("failed to get user's Home directory: %v\n " , err )
312- return
313- }
314- config .InstallDir = filepath .Join (homeDir , ".local/bin" )
315- tempDir , err := os .UserCacheDir ()
316- if err != nil {
317- fmt .Printf ("failed to get user's Cache directory: %v\n " , err )
318- return
319- }
320- config .CacheDir = filepath .Join (tempDir , "dbin_cache" )
321-
322- userConfigDir , err := os .UserConfigDir ()
323- if err != nil {
324- fmt .Printf ("failed to get user's Config directory: %v\n " , err )
325- return
326- }
327- config .LicenseDir = filepath .Join (userConfigDir , "dbin" , "licenses" )
310+ config .InstallDir = filepath .Join (xdg .BinHome )
311+ config .CacheDir = filepath .Join (xdg .CacheHome , "dbin_cache" )
312+ config .LicenseDir = filepath .Join (xdg .ConfigHome , "dbin" , "licenses" )
328313 config .CreateLicenses = true
329314
330315 config .Repositories = []repository {
331316 {
332- URL : fmt .Sprintf ("https://d.xplshn.com.ar/misc/cmd/%.1f/%s%s" , version , arch , ".lite.cbor.zst" ),
317+ URL : fmt .Sprintf ("https://d.xplshn.com.ar/misc/cmd/%.1f/%s%s" , version , arch , ".nlite.cbor.zst" ),
318+ FallbackURLs : []string {
319+ fmt .Sprintf ("https://github.com/xplshn/dbin-metadata/raw/refs/heads/master/misc/cmd/%.1f/%s%s" , version , arch , ".nlite.cbor.zst" ),
320+ },
333321 PubKeys : map [string ]string {
334322 "bincache" : "https://meta.pkgforge.dev/bincache/minisign.pub" ,
335323 "pkgcache" : "https://meta.pkgforge.dev/pkgcache/minisign.pub" ,
@@ -339,7 +327,7 @@ func setDefaultValues(config *config) {
339327 }
340328
341329 config .DisableTruncation = false
342- config .Limit = 9999
330+ config .Limit = 999999
343331 config .UseIntegrationHooks = true
344332 config .RetakeOwnership = false
345333 config .ProgressbarStyle = 1
0 commit comments