Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync-single-account.py #968

Merged
merged 1 commit into from
Nov 6, 2024
Merged

sync-single-account.py #968

merged 1 commit into from
Nov 6, 2024

Conversation

squeaky-pl
Copy link
Contributor

@squeaky-pl squeaky-pl commented Nov 5, 2024

This is something that I did over and over using sync-engine console to debug escalations and otherwise troubleshoot syncing of a single account. Since it is not obvious how to do it I wrapped it in a script so everybody can use it.

Comment on lines +29 to +30
sync_engine_class: ClassVar[type["FolderSyncEngine"]]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this out of an initializer so the thread class used to sync a single folder can be accessed without constructing a monitor. A monitor is a parent thread used to sync all the folders.

@@ -55,174 +55,6 @@
MAX_DOWNLOAD_COUNT = 1


class GmailSyncMonitor(ImapSyncMonitor):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just switched the order of classes here so I can access GmailFolderSyncEngine from GmailSyncMonitor

Comment on lines +53 to +68
@cache
def get_monitor_classes() -> dict[str, Type[BaseMailSyncMonitor]]:
"""
Return a dictionary mapping provider names to their respective monitor
"""
monitor_classes = {
module.PROVIDER: getattr(module, module.SYNC_MONITOR_CLS)
for module in module_registry.values()
if hasattr(module, "SYNC_MONITOR_CLS")
}

for provider_name, _ in providers.items():
if provider_name not in monitor_classes:
monitor_classes[provider_name] = monitor_classes["generic"]

return monitor_classes
Copy link
Contributor Author

@squeaky-pl squeaky-pl Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was extracted from SyncService intializer so I can use this from the script. This code is itself terribly dynamic but sync-engine was built to be extended by installing external modules like plugins, something that we don't do ourselves but I don't want to change it right now.

Comment on lines +435 to +436
class GmailSyncMonitor(ImapSyncMonitor):
sync_engine_class: ClassVar[type[FolderSyncEngine]] = GmailFolderSyncEngine
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this code was moved below with

sync_engine_class: ClassVar[type[FolderSyncEngine]] = GmailFolderSyncEngine

moved from the initializer to class body.

@squeaky-pl squeaky-pl merged commit 6c67bc5 into master Nov 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants