mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 13:25:21 +01:00
* Avoid redundant logging in migrations
Return the error and let the caller handle the logging of the error if
needed.
While here, defer m.Close() to the function boundary.
* Treat errors as values
Use %v rather than %s and pass the errors directly.
* Generate a wrapped error on stat-failure
* 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.
* Propagate errors upward
Failure in path generation was ignored. Propagate the errors upward the
call stack, so it can be handled at the level of orchestration.
* Warn on errors
Log errors rather than quenching them.
Errors are logged at the Warn-level for now.
* Check error when creating test databases
Use the builtin log package and stop the program fatally on error.
* Add warnings to uncheck task errors
Focus on the task system in a single commit, logging unchecked
errors as warnings.
* Warn-on-error in API routes
Look through the API routes, and make sure errors are being logged if
they occur. Prefer the Warn-log-level because none of these has proven
to be fatal in the system up until now.
* Propagate error when adding Util API
* Propagate error on adding util API
* Return unhandled error
* JS log API: propagate and log errors
* JS Plugins: log GQL addition failures.
* Warn on failure to write to stdin
* Warn on failure to stop task
* Wrap viper.BindEnv
The current viper code only errors if no name is provided, so it should
never fail. Rewrite the code flow to factor through a panic-function.
This removes error warnings from this part of the code.
* Log errors in concurrency test
If we can't initialize the configuration, treat the test as a failure.
* Warn on errors in configuration code
* Plug an unchecked error in gallery zip walking
* Warn on screenshot serving failure
* Warn on encoder screenshot failure
* Warn on errors in path-handling code
* Undo the errcheck on configurations for now.
* Use one-line initializers where applicable
rather than using
err := f()
if err!= nil { ..
prefer the shorter
if err := f(); err != nil { ..
If f() isn't too long of a name, or wraps a function with a body.
100 lines
3.5 KiB
Go
100 lines
3.5 KiB
Go
package config
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
// should be run with -race
|
|
func TestConcurrentConfigAccess(t *testing.T) {
|
|
i := GetInstance()
|
|
|
|
const workers = 8
|
|
//const loops = 1000
|
|
const loops = 200
|
|
var wg sync.WaitGroup
|
|
for k := 0; k < workers; k++ {
|
|
wg.Add(1)
|
|
go func(wk int) {
|
|
for l := 0; l < loops; l++ {
|
|
i.SetInitialConfig()
|
|
|
|
i.HasCredentials()
|
|
i.GetCPUProfilePath()
|
|
i.GetConfigFile()
|
|
i.GetConfigPath()
|
|
i.GetDefaultDatabaseFilePath()
|
|
i.GetStashPaths()
|
|
i.GetConfigFilePath()
|
|
i.Set(Cache, i.GetCachePath())
|
|
i.Set(Generated, i.GetGeneratedPath())
|
|
i.Set(Metadata, i.GetMetadataPath())
|
|
i.Set(Database, i.GetDatabasePath())
|
|
i.Set(JWTSignKey, i.GetJWTSignKey())
|
|
i.Set(SessionStoreKey, i.GetSessionStoreKey())
|
|
i.GetDefaultScrapersPath()
|
|
i.Set(Exclude, i.GetExcludes())
|
|
i.Set(ImageExclude, i.GetImageExcludes())
|
|
i.Set(VideoExtensions, i.GetVideoExtensions())
|
|
i.Set(ImageExtensions, i.GetImageExtensions())
|
|
i.Set(GalleryExtensions, i.GetGalleryExtensions())
|
|
i.Set(CreateGalleriesFromFolders, i.GetCreateGalleriesFromFolders())
|
|
i.Set(Language, i.GetLanguage())
|
|
i.Set(VideoFileNamingAlgorithm, i.GetVideoFileNamingAlgorithm())
|
|
i.Set(ScrapersPath, i.GetScrapersPath())
|
|
i.Set(ScraperUserAgent, i.GetScraperUserAgent())
|
|
i.Set(ScraperCDPPath, i.GetScraperCDPPath())
|
|
i.Set(ScraperCertCheck, i.GetScraperCertCheck())
|
|
i.Set(ScraperExcludeTagPatterns, i.GetScraperExcludeTagPatterns())
|
|
i.Set(StashBoxes, i.GetStashBoxes())
|
|
i.GetDefaultPluginsPath()
|
|
i.Set(PluginsPath, i.GetPluginsPath())
|
|
i.Set(Host, i.GetHost())
|
|
i.Set(Port, i.GetPort())
|
|
i.Set(ExternalHost, i.GetExternalHost())
|
|
i.Set(PreviewSegmentDuration, i.GetPreviewSegmentDuration())
|
|
i.Set(ParallelTasks, i.GetParallelTasks())
|
|
i.Set(ParallelTasks, i.GetParallelTasksWithAutoDetection())
|
|
i.Set(PreviewAudio, i.GetPreviewAudio())
|
|
i.Set(PreviewSegments, i.GetPreviewSegments())
|
|
i.Set(PreviewExcludeStart, i.GetPreviewExcludeStart())
|
|
i.Set(PreviewExcludeEnd, i.GetPreviewExcludeEnd())
|
|
i.Set(PreviewPreset, i.GetPreviewPreset())
|
|
i.Set(MaxTranscodeSize, i.GetMaxTranscodeSize())
|
|
i.Set(MaxStreamingTranscodeSize, i.GetMaxStreamingTranscodeSize())
|
|
i.Set(ApiKey, i.GetAPIKey())
|
|
i.Set(Username, i.GetUsername())
|
|
i.Set(Password, i.GetPasswordHash())
|
|
i.GetCredentials()
|
|
i.Set(MaxSessionAge, i.GetMaxSessionAge())
|
|
i.Set(CustomServedFolders, i.GetCustomServedFolders())
|
|
i.Set(CustomUILocation, i.GetCustomUILocation())
|
|
i.Set(MenuItems, i.GetMenuItems())
|
|
i.Set(SoundOnPreview, i.GetSoundOnPreview())
|
|
i.Set(WallShowTitle, i.GetWallShowTitle())
|
|
i.Set(CustomPerformerImageLocation, i.GetCustomPerformerImageLocation())
|
|
i.Set(WallPlayback, i.GetWallPlayback())
|
|
i.Set(MaximumLoopDuration, i.GetMaximumLoopDuration())
|
|
i.Set(AutostartVideo, i.GetAutostartVideo())
|
|
i.Set(ShowStudioAsText, i.GetShowStudioAsText())
|
|
i.Set(SlideshowDelay, i.GetSlideshowDelay())
|
|
i.GetCSSPath()
|
|
i.GetCSS()
|
|
i.Set(CSSEnabled, i.GetCSSEnabled())
|
|
i.Set(HandyKey, i.GetHandyKey())
|
|
i.Set(DLNAServerName, i.GetDLNAServerName())
|
|
i.Set(DLNADefaultEnabled, i.GetDLNADefaultEnabled())
|
|
i.Set(DLNADefaultIPWhitelist, i.GetDLNADefaultIPWhitelist())
|
|
i.Set(DLNAInterfaces, i.GetDLNAInterfaces())
|
|
i.Set(LogFile, i.GetLogFile())
|
|
i.Set(LogOut, i.GetLogOut())
|
|
i.Set(LogLevel, i.GetLogLevel())
|
|
i.Set(LogAccess, i.GetLogAccess())
|
|
i.Set(MaxUploadSize, i.GetMaxUploadSize())
|
|
}
|
|
wg.Done()
|
|
}(k)
|
|
}
|
|
|
|
wg.Wait()
|
|
}
|