Giter Site home page Giter Site logo

Comments (9)

choma avatar choma commented on May 19, 2024

Sorry, I was wrong when I tried to guess where the problem was.
I'm not sure of being right again, that's the reason I don't PR, but this change worked for me. I changed this in AbstractListener:

protected function _afterDeleteFile(Event $event) {
        $this->_handleLegacyEvent($event);
        $afterDeleteEvent = new Event('FileStorage.afterDeleteFile', $this, [
            'entity' => $event->result,
            'adapter' => $this->storageAdapter($event->result['adapter'])
        ]);
        EventManager::instance()->dispatch($afterDeleteEvent);
    }

with this:

protected function _afterDeleteFile(Event $event) {
        $this->_handleLegacyEvent($event);
        $afterDeleteEvent = new Event('FileStorage.afterDeleteFile', $this, [
            // use passed entity here...
            'entity' => $event->data['entity'],
            'adapter' => $this->storageAdapter($event->data['entity']->adapter) 
        ]);
        EventManager::instance()->dispatch($afterDeleteEvent);
    }

And now it works for me.

from cakephp-file-storage.

burzum avatar burzum commented on May 19, 2024

Hey, sorry for the delay but I'm very busy this week with work and private stuff. I'll review this in detail when I have the time. I understand the problem and see the fix but I need to review it more deeply and see if this doesn't have any side effects.

from cakephp-file-storage.

choma avatar choma commented on May 19, 2024

I'm not sure if it is related to this bug, but I've noted that even when the files are deleted correctly, the container folders are not. So I end up with a lot of empty nested folders. Is this the way it is supposed to work?

from cakephp-file-storage.

burzum avatar burzum commented on May 19, 2024

I'm aware of that but never gave it a priority because it doesn't hurt.

The problem is you need to know if the file resides alone on this folder or not to delete the folder without accidentally deleting other files. The default config is that it should use one folder at the end of the nested path for each file which is using the uuid as name. But if you configure it different you can end up with many files in the same folder.

from cakephp-file-storage.

burzum avatar burzum commented on May 19, 2024

@choma please try 1.1-dev I've fixed the code in the 1.1 branch.

from cakephp-file-storage.

choma avatar choma commented on May 19, 2024

Nope!
It didn't fixed the issue for me. You still need to change the 390 line, by this:

'adapter' => $this->storageAdapter($event->data['entity']->adapter)

There is where the bug is in fact, sorry if wasn't clear in my previous comments.
I just changed the previous line because I thought it would create other problems.

from cakephp-file-storage.

burzum avatar burzum commented on May 19, 2024

No problem, I've made the change.

Any reason you didn't do the change yourself and created a pull request?

from cakephp-file-storage.

choma avatar choma commented on May 19, 2024

I'm sorry I didn't. I'm still trying to understand the code, I'm not sure how the change will affect the rest of it. And I never learned to do php tests, so I'm not sure how to handle them.
But hopefully, with some more time using the plugin I'll be able to give you a hand :)

Thanks for the great plugin!

from cakephp-file-storage.

burzum avatar burzum commented on May 19, 2024

Welcome, I'm glad you like it. Let me know if you need something else.

I can't admit that the plugin isn't the most easy one to use but I think it is the most powerful on with the best architecture. And I keep improving it. 2.0 will drop a lot of legacy code and make things more easy. I'm not happy with the image processing right now, it's still to tight coupled and interwoven with the storage related code.

from cakephp-file-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.