mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-16 07:12:18 +01:00
Check if file exists instead of catching exceptions
This commit is contained in:
@@ -1029,6 +1029,11 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
var path = GetPolicyFilePath(user);
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return GetDefaultPolicy(user);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lock (_policySyncLock)
|
||||
@@ -1036,10 +1041,6 @@ namespace Emby.Server.Implementations.Library
|
||||
return (UserPolicy)_xmlSerializer.DeserializeFromFile(typeof(UserPolicy), path);
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return GetDefaultPolicy(user);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return GetDefaultPolicy(user);
|
||||
@@ -1128,6 +1129,11 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
var path = GetConfigurationFilePath(user);
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return new UserConfiguration();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lock (_configSyncLock)
|
||||
@@ -1135,10 +1141,6 @@ namespace Emby.Server.Implementations.Library
|
||||
return (UserConfiguration)_xmlSerializer.DeserializeFromFile(typeof(UserConfiguration), path);
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return new UserConfiguration();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return new UserConfiguration();
|
||||
|
||||
Reference in New Issue
Block a user