mirror of
https://github.com/usatiuk/dhfs.git
synced 2025-10-29 04:57:48 +01:00
actually working deletion
This commit is contained in:
@@ -437,7 +437,7 @@ public class DhfsFileServiceImpl implements DhfsFileService {
|
||||
|
||||
private void cleanupChunks(File f, Collection<String> uuids) {
|
||||
// FIXME:
|
||||
var inFile = new HashSet<>(f.getChunks().values());
|
||||
var inFile = useHashForChunks ? new HashSet<>(f.getChunks().values()) : Collections.emptySet();
|
||||
for (var cuuid : uuids) {
|
||||
if (inFile.contains(cuuid)) continue;
|
||||
var ci = jObjectManager.get(ChunkInfo.getNameFromHash(cuuid));
|
||||
|
||||
@@ -216,6 +216,13 @@ public class JObject<T extends JObjectData> implements Serializable {
|
||||
_lock.writeLock().unlock();
|
||||
}
|
||||
|
||||
public void discardData() {
|
||||
assertRWLock();
|
||||
if (!isDeleted())
|
||||
throw new IllegalStateException("Expected to be deleted when discarding data");
|
||||
_dataPart.set(null);
|
||||
}
|
||||
|
||||
static public void rwLockAll(List<JObject<?>> objects) {
|
||||
objects.stream().sorted(Comparator.comparingInt(System::identityHashCode)).forEach(JObject::rwLock);
|
||||
}
|
||||
|
||||
@@ -218,12 +218,14 @@ public class JObjectManagerImpl implements JObjectManager {
|
||||
|
||||
if (!m.getSavedRefs().isEmpty())
|
||||
refs = m.getSavedRefs().stream();
|
||||
if (d != null)
|
||||
refs = Streams.concat(refs, d.extractRefs().stream());
|
||||
if (object.getData() != null)
|
||||
refs = Streams.concat(refs, object.getData().extractRefs().stream());
|
||||
|
||||
object.discardData();
|
||||
|
||||
refs.forEach(c -> get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (mc, dc, bc, ic) -> {
|
||||
mc.removeRef(object.getName());
|
||||
tryQuickDelete(ref);
|
||||
// tryQuickDelete(ref);
|
||||
return null;
|
||||
})));
|
||||
|
||||
|
||||
@@ -74,22 +74,20 @@ public class JObjectRefProcessor {
|
||||
got.get().runWriteLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (m, d, v, i) -> {
|
||||
if (m.isDeleted()) return null;
|
||||
if (m.getRefcount() > 0) return null;
|
||||
if (!m.isSeen()) {
|
||||
jObjectManager.tryQuickDelete(got.get());
|
||||
return null;
|
||||
}
|
||||
|
||||
got.get().tryResolve(JObject.ResolutionStrategy.LOCAL_ONLY);
|
||||
|
||||
Log.info("Deleting " + m.getName());
|
||||
Log.trace("Deleting " + m.getName());
|
||||
m.delete();
|
||||
|
||||
Stream<String> refs = Stream.empty();
|
||||
|
||||
if (!m.getSavedRefs().isEmpty())
|
||||
refs = m.getSavedRefs().stream();
|
||||
if (d != null)
|
||||
refs = Streams.concat(refs, d.extractRefs().stream());
|
||||
if (got.get().getData() != null)
|
||||
refs = Streams.concat(refs, got.get().getData().extractRefs().stream());
|
||||
|
||||
got.get().discardData();
|
||||
|
||||
refs.forEach(c -> {
|
||||
jObjectManager.get(c).ifPresent(ref -> ref.runWriteLocked(JObject.ResolutionStrategy.NO_RESOLUTION, (mc, dc, bc, ic) -> {
|
||||
|
||||
@@ -130,6 +130,7 @@ public class JObjectResolver {
|
||||
|
||||
public void notifyWriteData(JObject<?> self) {
|
||||
self.assertRWLock();
|
||||
jObjectWriteback.markDirty(self.getName(), self);
|
||||
if (self.isResolved())
|
||||
invalidationQueueService.pushInvalidationToAll(self.getName(), !self.getMeta().isSeen());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user