mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Lint checks phase 2 (#1747)
* Log 3 unchecked errors Rather than ignore errors, log them at the WARNING log level. The server has been functioning without these, so assume they are not at the ERROR level. * Log errors in concurrency test If we can't initialize the configuration, treat the test as a failure. * Undo the errcheck on configurations for now. * Handle unchecked errors in pkg/manager * Resolve unchecked errors * Handle DLNA/DMS unchecked errors * Handle error checking in concurrency test Generalize config initialization, so we can initialize a configuration without writing it to disk. Use this in the test case, since otherwise the test fails to write. * Handle the remaining unchecked errors * Heed gosimple in update test * Use one-line if-initializer statements While here, fix a wrong variable capture error. * testing.T doesn't support %w use %v instead which is supported. * Remove unused query builder functions The Int/String criterion handler functions are now generalized. Thus, there's no need to keep these functions around anymore. * Mark filterBuilder.addRecursiveWith nolint The function is useful in the future and no other refactors are looking nice. Keep the function around, but tell the linter to ignore it. * Remove utils.Btoi There are no users of this utility function * Return error on scan failure If we fail to scan the row when looking for the unique checksum index, then report the error upwards. * Fix comments on exported functions * Fix typos * Fix startup error
This commit is contained in:
@@ -110,11 +110,15 @@ func Initialize() *singleton {
|
||||
logger.Warnf("config file %snot found. Assuming new system...", cfgFile)
|
||||
}
|
||||
|
||||
initFFMPEG()
|
||||
if err = initFFMPEG(); err != nil {
|
||||
logger.Warnf("could not initialize FFMPEG subsystem: %v", err)
|
||||
}
|
||||
|
||||
// if DLNA is enabled, start it now
|
||||
if instance.Config.GetDLNADefaultEnabled() {
|
||||
instance.DLNAService.Start(nil)
|
||||
if err := instance.DLNAService.Start(nil); err != nil {
|
||||
logger.Warnf("could not start DLNA service: %v", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -134,7 +138,9 @@ func initProfiling(cpuProfilePath string) {
|
||||
logger.Infof("profiling to %s", cpuProfilePath)
|
||||
|
||||
// StopCPUProfile is defer called in main
|
||||
pprof.StartCPUProfile(f)
|
||||
if err = pprof.StartCPUProfile(f); err != nil {
|
||||
logger.Warnf("could not start CPU profiling: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func initFFMPEG() error {
|
||||
@@ -182,7 +188,9 @@ func initLog() {
|
||||
// configuration has been set. Should only be called if the configuration
|
||||
// is valid.
|
||||
func (s *singleton) PostInit() error {
|
||||
s.Config.SetInitialConfig()
|
||||
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()
|
||||
@@ -201,8 +209,12 @@ func (s *singleton) PostInit() error {
|
||||
const deleteTimeout = 1 * time.Second
|
||||
|
||||
utils.Timeout(func() {
|
||||
utils.EmptyDir(instance.Paths.Generated.Downloads)
|
||||
utils.EmptyDir(instance.Paths.Generated.Tmp)
|
||||
if err := utils.EmptyDir(instance.Paths.Generated.Downloads); err != nil {
|
||||
logger.Warnf("could not empty Downloads directory: %v", err)
|
||||
}
|
||||
if err := utils.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
|
||||
@@ -236,11 +248,21 @@ func (s *singleton) RefreshConfig() {
|
||||
s.Paths = paths.NewPaths(s.Config.GetGeneratedPath())
|
||||
config := s.Config
|
||||
if config.Validate() == nil {
|
||||
utils.EnsureDir(s.Paths.Generated.Screenshots)
|
||||
utils.EnsureDir(s.Paths.Generated.Vtt)
|
||||
utils.EnsureDir(s.Paths.Generated.Markers)
|
||||
utils.EnsureDir(s.Paths.Generated.Transcodes)
|
||||
utils.EnsureDir(s.Paths.Generated.Downloads)
|
||||
if err := utils.EnsureDir(s.Paths.Generated.Screenshots); err != nil {
|
||||
logger.Warnf("could not create directory for Screenshots: %v", err)
|
||||
}
|
||||
if err := utils.EnsureDir(s.Paths.Generated.Vtt); err != nil {
|
||||
logger.Warnf("could not create directory for VTT: %v", err)
|
||||
}
|
||||
if err := utils.EnsureDir(s.Paths.Generated.Markers); err != nil {
|
||||
logger.Warnf("could not create directory for Markers: %v", err)
|
||||
}
|
||||
if err := utils.EnsureDir(s.Paths.Generated.Transcodes); err != nil {
|
||||
logger.Warnf("could not create directory for Transcodes: %v", err)
|
||||
}
|
||||
if err := utils.EnsureDir(s.Paths.Generated.Downloads); err != nil {
|
||||
logger.Warnf("could not create directory for Downloads: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +326,9 @@ func (s *singleton) Setup(input models.SetupInput) error {
|
||||
|
||||
s.Config.FinalizeSetup()
|
||||
|
||||
initFFMPEG()
|
||||
if err := initFFMPEG(); err != nil {
|
||||
return fmt.Errorf("error initializing FFMPEG subsystem: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user