aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs49
1 files changed, 27 insertions, 22 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
index d9544db..ff10e7f 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
60 60
61 private bool m_Enabled = false; 61 private bool m_Enabled = false;
62 62
63 public object diskLock = new object(); 63 public static object diskLock = new object();
64 64
65 public bool doMeshFileCache = true; 65 public bool doMeshFileCache = true;
66 66
@@ -1426,13 +1426,13 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1426 { 1426 {
1427 if (File.Exists(filename)) 1427 if (File.Exists(filename))
1428 { 1428 {
1429 FileStream stream = null;
1430 try 1429 try
1431 { 1430 {
1432 stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); 1431 using(FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
1433 BinaryFormatter bformatter = new BinaryFormatter(); 1432 {
1434 1433// BinaryFormatter bformatter = new BinaryFormatter();
1435 mesh = Mesh.FromStream(stream, key); 1434 mesh = Mesh.FromStream(stream,key);
1435 }
1436 1436
1437 } 1437 }
1438 catch (Exception e) 1438 catch (Exception e)
@@ -1443,13 +1443,17 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1443 filename, e.Message, e.StackTrace); 1443 filename, e.Message, e.StackTrace);
1444 } 1444 }
1445 1445
1446 if (stream != null) 1446 try
1447 stream.Close(); 1447 {
1448 if (mesh == null || !ok)
1449 File.Delete(filename);
1450 else
1451 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
1452 }
1453 catch
1454 {
1455 }
1448 1456
1449 if (mesh == null || !ok)
1450 File.Delete(filename);
1451 else
1452 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
1453 } 1457 }
1454 } 1458 }
1455 1459
@@ -1458,7 +1462,6 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1458 1462
1459 private void StoreToFileCache(AMeshKey key, Mesh mesh) 1463 private void StoreToFileCache(AMeshKey key, Mesh mesh)
1460 { 1464 {
1461 Stream stream = null;
1462 bool ok = false; 1465 bool ok = false;
1463 1466
1464 // Make sure the target cache directory exists 1467 // Make sure the target cache directory exists
@@ -1476,8 +1479,8 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1476 Directory.CreateDirectory(dir); 1479 Directory.CreateDirectory(dir);
1477 } 1480 }
1478 1481
1479 stream = File.Open(filename, FileMode.Create); 1482 using(Stream stream = File.Open(filename, FileMode.Create))
1480 ok = mesh.ToStream(stream); 1483 ok = mesh.ToStream(stream);
1481 } 1484 }
1482 catch (IOException e) 1485 catch (IOException e)
1483 { 1486 {
@@ -1487,15 +1490,17 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1487 ok = false; 1490 ok = false;
1488 } 1491 }
1489 1492
1490 if (stream != null) 1493 if (!ok && File.Exists(filename))
1491 stream.Close();
1492
1493 if (File.Exists(filename))
1494 { 1494 {
1495 if (ok) 1495 try
1496 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow); 1496 {
1497 else
1498 File.Delete(filename); 1497 File.Delete(filename);
1498 }
1499 catch (IOException e)
1500 {
1501 m_log.ErrorFormat(
1502 "[MESH CACHE]: Failed to delete file {0}",filename);
1503 }
1499 } 1504 }
1500 } 1505 }
1501 } 1506 }