@@ -142,6 +142,19 @@ func main() {
142142
143143 banner ()
144144
145+ if flags .remote != "" {
146+ closeFS , err := setupRemoteConfiguration (flags .remote )
147+ if err != nil {
148+ // need to setup console logging to display the error message
149+ closeLogger := setupLogging (nil )
150+ defer closeLogger ()
151+ clog .Error (err )
152+ exitCode = constants .ExitCannotSetupRemoteConfiguration
153+ return
154+ }
155+ shutdown .AddHook (closeFS )
156+ }
157+
145158 // resticprofile own commands (configuration file may not be loaded)
146159 if len (flags .resticArgs ) > 0 {
147160 if ownCommands .Exists (flags .resticArgs [0 ], false ) {
@@ -280,21 +293,22 @@ func banner() {
280293func loadConfig (flags commandLineFlags , silent bool ) (cfg * config.Config , global * config.Global , err error ) {
281294 fs := afero .NewOsFs ()
282295
283- if flags .remote != "" {
284- // fs = afero.NewMemMapFs()
285- // parameters, err := loadRemoteConfiguration(fs, flags.remote)
286- _ , parameters , err := loadRemoteFiles (flags .remote )
287- if err != nil {
288- return nil , nil , fmt .Errorf ("cannot load remote configuration: %w" , err )
289- }
290- // we should probably move this to the context (and keep flags intact)
291- if flags .config == constants .DefaultConfigurationFile {
292- flags .config = parameters .ConfigurationFile
293- }
294- if flags .name == constants .DefaultProfileName {
295- flags .name = parameters .ProfileName
296- }
297- }
296+ // if flags.remote != "" {
297+ // // fs = afero.NewMemMapFs()
298+ // // parameters, err := loadRemoteConfiguration(fs, flags.remote)
299+ // os.Chdir()
300+ // _, parameters, err := loadRemoteFiles(flags.remote)
301+ // if err != nil {
302+ // return nil, nil, fmt.Errorf("cannot load remote configuration: %w", err)
303+ // }
304+ // // we should probably move this to the context (and keep flags intact)
305+ // if flags.config == constants.DefaultConfigurationFile {
306+ // flags.config = parameters.ConfigurationFile
307+ // }
308+ // if flags.name == constants.DefaultProfileName {
309+ // flags.name = parameters.ProfileName
310+ // }
311+ // }
298312
299313 var configFile string
300314 if configFile , err = filesearch .FindConfigurationFile (fs , flags .config ); err == nil {
0 commit comments