aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-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);