flow-development-collection icon indicating copy to clipboard operation
flow-development-collection copied to clipboard

Problem deleting many resources at once

Open neos-bot opened this issue 9 years ago • 4 comments

Jira issue originally created by user kaystrobach:

prerequisites:

  • upload atleast 2 files with the exact same sha1 to a collection (filename is not important)
  • fetch all resources of the collection and iterate over it calling resource manager -> deleteResource
16-02-25 17:38:12 4011       DEBUG     Flow                 Not removing storage data of resource test.xlsx (8c60383fe08014cb8246cd8f6b079d9cf67dcf48) because it is still in use by 1 other Resource object(s).
16-02-25 17:38:12 4011       DEBUG     Flow                 Not removing storage data of resource test.xlsx (8c60383fe08014cb8246cd8f6b079d9cf67dcf48) because it is still in use by 1 other Resource object(s).

So the result, is that the file is still in the Data/Persistent directory, but if i just create on file with the same sha1 hash it can be deleted with the same behaviour

imho ResourceManager.php:deleteResource should not only count the objects, but should also check, wether these objects are deleted or not - agreed?

So the expected behaviour would be that the files are removed from the filesystem

example php code to produce the error (taken form a controller)

    public function cleanUpAction() {
        /*** @var QueryResultInterface $resources **/
        $resources = $this->resourceRepository->findByCollectionName('SBS.SingleSignOn:TempImportCollection');

        /*** @var Resource $object **/
        foreach($resources as $resource) {
            $this->resourceManager->deleteResource($resource);
            $this->persistenceManager->persistAll();
        }

        $this->redirect('newUsers');
    }

Jira-URL: https://jira.neos.io/browse/FLOW-438

neos-bot avatar Feb 25 '16 18:02 neos-bot