aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2009-10-04 09:56:54 -0700
committerDiva Canto2009-10-04 09:56:54 -0700
commitfe9cca64dea714583c09854a90f2c13fecb12d29 (patch)
tree132c5e4909a124eac3f3fc24db18048b76b136e2
parentMake sure to close the file streams on the FlotsamCache, even if something fa... (diff)
downloadopensim-SC-fe9cca64dea714583c09854a90f2c13fecb12d29.zip
opensim-SC-fe9cca64dea714583c09854a90f2c13fecb12d29.tar.gz
opensim-SC-fe9cca64dea714583c09854a90f2c13fecb12d29.tar.bz2
opensim-SC-fe9cca64dea714583c09854a90f2c13fecb12d29.tar.xz
Stream needs to be closed before the file can be moved...
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs11
1 files changed, 6 insertions, 5 deletions
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
499 private void WriteFileCache(string filename, AssetBase asset) 499 private void WriteFileCache(string filename, AssetBase asset)
500 { 500 {
501 Stream stream = null; 501 Stream stream = null;
502 // Make sure the target cache directory exists
503 string directory = Path.GetDirectoryName(filename);
504 // Write file first to a temp name, so that it doesn't look
505 // like it's already cached while it's still writing.
506 string tempname = Path.Combine(directory, Path.GetRandomFileName());
502 try 507 try
503 { 508 {
504 // Make sure the target cache directory exists
505 string directory = Path.GetDirectoryName(filename);
506 if (!Directory.Exists(directory)) 509 if (!Directory.Exists(directory))
507 { 510 {
508 Directory.CreateDirectory(directory); 511 Directory.CreateDirectory(directory);
509 } 512 }
510 513
511 // Write file first to a temp name, so that it doesn't look
512 // like it's already cached while it's still writing.
513 string tempname = Path.Combine(directory, Path.GetRandomFileName());
514 stream = File.Open(tempname, FileMode.Create); 514 stream = File.Open(tempname, FileMode.Create);
515 BinaryFormatter bformatter = new BinaryFormatter(); 515 BinaryFormatter bformatter = new BinaryFormatter();
516 bformatter.Serialize(stream, asset); 516 bformatter.Serialize(stream, asset);
517 stream.Close();
517 518
518 // Now that it's written, rename it so that it can be found. 519 // Now that it's written, rename it so that it can be found.
519 File.Move(tempname, filename); 520 File.Move(tempname, filename);