]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ClusterImpl.java
Some fixes/cleanup for cluster table size caching logic.
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / ClusterImpl.java
index 1baef88ac4fe9af7d9b664cef1b8026aff078f47..4c8e19853f6b15ba9de73e3f08581580c9a25f60 100644 (file)
@@ -118,12 +118,17 @@ public abstract class ClusterImpl extends ClusterBase implements Modifier, Colle
     
     public long getCachedSize() {
         if(dirtySizeInBytes) {
+            long oldSize = sizeInBytes;
+            if (oldSize > 0)
+                clusterTable.adjustCachedSize(-oldSize, this);
             try {
                 sizeInBytes = getUsedSpace();
-                //System.err.println("recomputed size of cluster " + getClusterId() + " => " + sizeInBytes);
+                //System.out.println("recomputed size of cluster " + getClusterId() + ": " + oldSize + " => " + sizeInBytes);
             } catch (DatabaseException e) {
                 Logger.defaultLogError(e);
             }
+            if (sizeInBytes != 0)
+                clusterTable.adjustCachedSize(sizeInBytes, this);
             dirtySizeInBytes = false;
         }
         return sizeInBytes;