|
|
|
@ -36,24 +36,22 @@ namespace Emby.Server.Implementations.AppBase
|
|
|
|
|
configuration = Activator.CreateInstance(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var stream = new MemoryStream())
|
|
|
|
|
{
|
|
|
|
|
xmlSerializer.SerializeToStream(configuration, stream);
|
|
|
|
|
|
|
|
|
|
// Take the object we just got and serialize it back to bytes
|
|
|
|
|
var newBytes = stream.ToArray();
|
|
|
|
|
using var stream = new MemoryStream();
|
|
|
|
|
xmlSerializer.SerializeToStream(configuration, stream);
|
|
|
|
|
|
|
|
|
|
// If the file didn't exist before, or if something has changed, re-save
|
|
|
|
|
if (buffer == null || !buffer.SequenceEqual(newBytes))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
|
|
|
|
// Take the object we just got and serialize it back to bytes
|
|
|
|
|
var newBytes = stream.ToArray();
|
|
|
|
|
|
|
|
|
|
// Save it after load in case we got new items
|
|
|
|
|
File.WriteAllBytes(path, newBytes);
|
|
|
|
|
}
|
|
|
|
|
// If the file didn't exist before, or if something has changed, re-save
|
|
|
|
|
if (buffer == null || !buffer.SequenceEqual(newBytes))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
|
|
|
|
|
|
|
|
|
return configuration;
|
|
|
|
|
// Save it after load in case we got new items
|
|
|
|
|
File.WriteAllBytes(path, newBytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return configuration;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|