From fe9cca64dea714583c09854a90f2c13fecb12d29 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 4 Oct 2009 09:56:54 -0700 Subject: Stream needs to be closed before the file can be moved... --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 1dc40bc..c0bb70c 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -499,21 +499,22 @@ namespace Flotsam.RegionModules.AssetCache private void WriteFileCache(string filename, AssetBase asset) { Stream stream = null; + // Make sure the target cache directory exists + string directory = Path.GetDirectoryName(filename); + // Write file first to a temp name, so that it doesn't look + // like it's already cached while it's still writing. + string tempname = Path.Combine(directory, Path.GetRandomFileName()); try { - // Make sure the target cache directory exists - string directory = Path.GetDirectoryName(filename); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } - // Write file first to a temp name, so that it doesn't look - // like it's already cached while it's still writing. - string tempname = Path.Combine(directory, Path.GetRandomFileName()); stream = File.Open(tempname, FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(stream, asset); + stream.Close(); // Now that it's written, rename it so that it can be found. File.Move(tempname, filename); -- cgit v1.1