Skip to content

Mirror and copy use cases and questions #466

Open
@DamnedScholar

Description

@DamnedScholar

Pardon me if this has come up before. I did an issue search for on_copy and didn't find any discussion that seemed specific to what I'm thinking about.

I've got a server where I've been thinking for a while about using an existing Dropbox as a file store for a website, and this library with the Dropbox driver is absolutely the lightest-weight and most Python-friendly way I've come across. I have a class set up to automagically copy things to my server, which I can boot up with Celery at start and a few minutes later have years of content preloaded. I would like to add in Sentry instrumentation so that I can record each of the sync tasks and track file changes. In looking through the API, I initially found fs.copy.copy_fs(), which has an on_copy callback, perfect for dropping a log message to be slurped up by Sentry, but it doesn't have any affordances for deleting files. fs.mirror.mirror() deletes as it goes, but doesn't provide an on_copy method. It would make sense for both methods to have access to that behavior, and furthermore it would make sense for the mirror() call to have an on_delete callback.

Could it make more sense for callback functions like these to live on Walker? It already has on_error, so moving the full suite of lifecycle callbacks over would just be standardizing the pattern. That might have an added benefit of allowing for reusable, specialized Walker subclasses, like one that knows how to report all actions to a specific logging service. Right now, my Dropbox/PyFS wrapper class is in a file with Sentry SDK imports and code, but if I wanted to implement the same behavior in another module, I'd have to repeat all that, or I could build a SentryWalker. on_copy=SentryWalker.on_copy will do for now, but feels gross.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions