Source:
<code>private State initState() throws IOException { State state = null; try { state = load(); System.out.println("Successfully loaded usage-state from "+ this.statePath); } catch (IOException ioe) { System.out.println("Could not read usage-state from "+ this.statePath); state = new State( new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); } try { for (Map.Entry<PublicKeyHash, Stat> entry : state.currentView.entrySet()) { PublicKeyHash writerKey = entry.getKey(); Stat stat = entry.getValue(); MaybeMultihash rootHash = mutable.getPointerTarget(writerKey, dht).get(); boolean isChanged = stat.target.equals(rootHash); if (isChanged) { long updatedSize = dht.getRecursiveBlockSize(rootHash.get()).get(); long deltaUsage = updatedSize - stat.directRetainedStorage; state.usage.get(stat.owner).confirmUsage(writerKey, deltaUsage); Set<PublicKeyHash> directOwnedKeys = WriterData.getDirectOwnedKeys(writerKey, mutable, dht); List<PublicKeyHash> newOwnedKeys = directOwnedKeys.stream() .filter(key -> !stat.ownedKeys.contains(key)) .collect(Collectors.toList()); for (PublicKeyHash newOwnedKey : newOwnedKeys) { currentView.putIfAbsent(newOwnedKey, new Stat(stat.owner, MaybeMultihash.empty(), 0, Collections.emptySet())); processMutablePointerEvent(newOwnedKey, MaybeMultihash.empty(), mutable.getPointerTarget(newOwnedKey, dht).get()); } stat.update(rootHash, directOwnedKeys, updatedSize); } } } catch (InterruptedException | ExecutionException ex) { throw new IOException(ex); } calculateUsage(); Runtime.getRuntime().addShutdownHook(new Thread(this::close)); <START> Files.deleteIfExists(statePath); <END> return state; }</code><technical_language>delete it? Surely want atomically overwrite next time serialize</technical_language>

Target:
private State initState() throws IOException { State state = null; try { state = load(); System.out.println("Successfully loaded usage-state from "+ this.statePath); } catch (IOException ioe) { System.out.println("Could not read usage-state from "+ this.statePath); state = new State( new ConcurrentHashMap<>(), new ConcurrentHashMap<>()); } try { for (Map.Entry<PublicKeyHash, Stat> entry : state.currentView.entrySet()) { PublicKeyHash ownerKey = entry.getKey(); Stat stat = entry.getValue(); MaybeMultihash rootHash = mutable.getPointerTarget(ownerKey, ownerKey, dht).get(); boolean isChanged = stat.target.equals(rootHash); if (isChanged) { long updatedSize = dht.getRecursiveBlockSize(rootHash.get()).get(); long deltaUsage = updatedSize - stat.directRetainedStorage; state.usage.get(stat.owner).confirmUsage(ownerKey, deltaUsage); Set<PublicKeyHash> directOwnedKeys = WriterData.getDirectOwnedKeys(ownerKey, ownerKey, mutable, dht); List<PublicKeyHash> newOwnedKeys = directOwnedKeys.stream() .filter(key -> !stat.ownedKeys.contains(key)) .collect(Collectors.toList()); for (PublicKeyHash newOwnedKey : newOwnedKeys) { state.currentView.putIfAbsent(newOwnedKey, new Stat(stat.owner, MaybeMultihash.empty(), 0, Collections.emptySet())); processMutablePointerEvent(ownerKey, newOwnedKey, MaybeMultihash.empty(), mutable.getPointerTarget(ownerKey, newOwnedKey, dht).get()); } stat.update(rootHash, directOwnedKeys, updatedSize); } } } catch (InterruptedException | ExecutionException ex) { throw new IOException(ex); } Runtime.getRuntime().addShutdownHook(new Thread(this::close)); return state; }