func (s *Manager) PostInit(ctx context.Context) error {
	if err := s.Config.SetInitialConfig(); err != nil {
		logger.Warnf("could not set initial configuration: %v", err)
	}

	s.Paths = paths.NewPaths(s.Config.GetGeneratedPath())
	s.RefreshConfig()
	s.SessionStore = session.NewStore(s.Config)
	s.PluginCache.RegisterSessionStore(s.SessionStore)

	if err := s.PluginCache.LoadPlugins(); err != nil {
		logger.Errorf("Error reading plugin configs: %s", err.Error())
	}

	s.ScraperCache = instance.initScraperCache()
	writeStashIcon()

	// clear the downloads and tmp directories
	// #1021 - only clear these directories if the generated folder is non-empty
	if s.Config.GetGeneratedPath() != "" {
		const deleteTimeout = 1 * time.Second

		utils.Timeout(func() {
			if err := fsutil.EmptyDir(instance.Paths.Generated.Downloads); err != nil {
				logger.Warnf("could not empty Downloads directory: %v", err)
			}
			if err := fsutil.EmptyDir(instance.Paths.Generated.Tmp); err != nil {
				logger.Warnf("could not empty Tmp directory: %v", err)
			}
		}, deleteTimeout, func(done chan struct{}) {
			logger.Info("Please wait. Deleting temporary files...") // print
			<-done                                                  // and wait for deletion
			logger.Info("Temporary files deleted.")
		})
	}

	if err := database.Initialize(s.Config.GetDatabasePath()); err != nil {
		return err
	}

	if database.Ready() == nil {
		s.PostMigrate(ctx)
	}

	return nil
}
// PostInit initialises the paths, caches and txnManager after the initial
// configuration has been set. Should only be called if the configuration
// is valid.
PostInit initialises the paths, caches and txnManager after the initial
configuration has been set. Should only be called if the configuration
is valid.
// PostInit initialises the paths caches and txnManager after the initial // configuration has been set . Should only be called if the configuration // is valid .
func (s *Manager) PostInit(ctx context.Context) error {
	if err := s.Config.SetInitialConfig(); err != nil {
		logger.Warnf("could not set initial configuration: %v", err)
	}
	s.Paths = paths.NewPaths(s.Config.GetGeneratedPath())
	s.RefreshConfig()
	s.SessionStore = session.NewStore(s.Config)
	s.PluginCache.RegisterSessionStore(s.SessionStore)
	if err := s.PluginCache.LoadPlugins(); err != nil {
		logger.Errorf("Error reading plugin configs: %s", err.Error())
	}
	s.ScraperCache = instance.initScraperCache()
	writeStashIcon()
	if s.Config.GetGeneratedPath() != "" {
		const deleteTimeout = 1 * time.Second
		utils.Timeout(func() {
			if err := fsutil.EmptyDir(instance.Paths.Generated.Downloads); err != nil {
				logger.Warnf("could not empty Downloads directory: %v", err)
			}
			if err := fsutil.EmptyDir(instance.Paths.Generated.Tmp); err != nil {
				logger.Warnf("could not empty Tmp directory: %v", err)
			}
		}, deleteTimeout, func(done chan struct{}) {
			logger.Info("Please wait. Deleting temporary files...") 
			<-done                                                  
			logger.Info("Temporary files deleted.")
		})
	}
	if err := database.Initialize(s.Config.GetDatabasePath()); err != nil {
		return err
	}
	if database.Ready() == nil {
		s.PostMigrate(ctx)
	}
	return nil
}
func ( s * Manager ) PostInit ( ctx context . Context ) error { if err := s . Config . SetInitialConfig ( ) ; err != nil { logger . Warnf ( " " , err ) } s . Paths = paths . NewPaths ( s . Config . GetGeneratedPath ( ) ) s . RefreshConfig ( ) s . SessionStore = session . NewStore ( s . Config ) s . PluginCache . RegisterSessionStore ( s . SessionStore ) if err := s . PluginCache . LoadPlugins ( ) ; err != nil { logger . Errorf ( " " , err . Error ( ) ) } s . ScraperCache = instance . initScraperCache ( ) writeStashIcon ( ) if s . Config . GetGeneratedPath ( ) != " " { const deleteTimeout = 1 * time . Second utils . Timeout ( func ( ) { if err := fsutil . EmptyDir ( instance . Paths . Generated . Downloads ) ; err != nil { logger . Warnf ( " " , err ) } if err := fsutil . EmptyDir ( instance . Paths . Generated . Tmp ) ; err != nil { logger . Warnf ( " " , err ) } } , deleteTimeout , func ( done chan struct { } ) { logger . Info ( " " ) <- done logger . Info ( " " ) } ) } if err := database . Initialize ( s . Config . GetDatabasePath ( ) ) ; err != nil { return err } if database . Ready ( ) == nil { s . PostMigrate ( ctx ) } return nil }
PostInit initialises the paths, caches and txnManager after the initial
configuration has been set.
PostInit initialises the paths caches and txnManager after the initial configuration has been set .
// clear the downloads and tmp directories // #1021 - only clear these directories if the generated folder is non-empty // print // and wait for deletion