-
Notifications
You must be signed in to change notification settings - Fork 313
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
[Bug] Duplicated syles saved on cloud #1906
Comments
When you create a style, it is not the same style in your cloud.
When importing styles, I think the importer will check if there are duplicated names and ask you whether to keep both of them. So you can sync first before importing styles. However, you won't want to import those styles if they are synced and in your database. |
I still suggest deleting them manually because clearing the database won't clear your cloud. You have three options:
|
I checked what you mentioned and I could verify that Stylus handles properly when importing the same user styles and does not duplicate them. So as you explained, the problem only happens when:
Is there a way to let Stylus detect the local styles before pulling to check if they are already present? If not I am ok with the workaround you proposed, but I think it could be a nice feature to have to avoid this problem. In the end, I decided to use a simple auto clicker script to manually remove all the styles one by one and then sync the changes to remove all of them from the cloud. |
It does but the sync manager uses an ID to identify a style. This allows you to rename a style and it will still sync. I think you can try exporting your backup again after sync, so it can store ID to the backup. However, if you want to import some kinds of brand new styles collection, they will be installed one by one resulting in different IDs. |
If styles have the same sourceCode or the same sections code, we should either automatically assume it's the same style and forcefully change the local style's sync id or display a confirmation dialog with all such styles so the user can confirm the assumptions. |
This will prevent us from duplicating styles.
The sync won't work if two documents use the same ID. If we merge two documents, it will become a new version and trigger the sync again which may result in an infinite loop.
I think this is the most feasible. We can't use this on sync since sync happens in the background, but it shouldn't be hard to display a message/button in the manager which launches the de-dupe tool from the importer. To prevent data loss, we may want to implement a "trash" first. |
That would arguably affect one user out of a million. 99.999% of users don't duplicate styles or at least they would change the name, so we can add a check for the same name to ensure it's indeed a duplicate.
Yeah, I should have said that the sync'd style would overwrite the local style in case the code+name is the same. |
I suggest the simpler, the better. For users, just don't import the same source code multiple times, or they will have multiple styles. Note that importing to each of three synced machines == importing three times to a single machine. For Stylus, avoid developing an algorithm to guess which styles are 99.999% similar. |
The way I see it the similarity is exactly 100%, not 99.999%. |
Also, the simple solution is always something that just works out of the box automatically without additional user involvement. My suggestion is to ignore the theoretical inconvenience to one user in a million and just clobber the local style if its code and name are equal to the remote style. |
How would it handle duplicated styles on the cloud or styles both on the cloud and local? |
Normally there are no duplicates in the cloud and no duplicates locally, so the automatic resolution is rather trivial: overwrite the local unsync'd style if its code and the name are exactly the same as the remote style. |
In this issue, they are both in the cloud and local machines. If it is for common cases, we shouldn't add this duplicate check to each sync pull. Since normally there are no duplicates in the cloud and no duplicates locally.
How to identify an unsync'd style? |
Here is a small demonstration of how this kind of automatic deletion may lead to data loss: Suppose A has
In reality, a company may use never-delete-anything policy, and let the boss/manager to handle version conflicts or backups. |
Indeed.
Its _rev is not present in the cloud.
There won't be any since deduplication applies only to unsync'd styles. We can also start by limiting it to external (updatable) styles. Either way, the current behavior is super inconvenient and must change. |
Can you elaborate?
One practical method is to only run the dedupe tool on the first sync. During the first sync, we can assume all styles are unsync'd:
But it won't work with synced clients e.g.
Now B will have two FOOBAR. |
Sorry, I meant |
If the cloud supports HEAD requests, it should be possible to request the cloud and ask for the existence. However, if there was an incomplete sync, there might be staled files left on the cloud resulting to false positive. There should be no false negative since db-to-cloud was designed to prevent data loss. The cost is very large though. Usually a single pull can be done by 5 requests: LOCK -> meta -> changes -> file -> UNLOCK. If we want to ask the cloud, the number of requests will increase with the number of local styles. |
I think we can limit it to the first sync after import. |
If that is the only case, we probably don't need to ask the cloud and can reuse the dedupe logic from the importer:
|
Looks complicated to the user. I want it to be automatic. Given the possibility of a mistake, the ideal solution would be two-fold: 1) automatic deduplication on first sync + 2) moving the local duplicates into a trash can. |
Description
When pulling styles from cloud, it won't detect it they are already present in the local storage, so all of them are downloaded again and gets duplicated. If we sync the styles, all of them are pushed duplicated.
Because of this, every time I do a clean installation of stylus without any styles, when I try to pull my styles it will always pull a bunch of duplicated styles.
P.D. I have the styles synced only to Google Drive, but I guess there is no difference in trying to store them in other storage providers.
System Information
Screenshots, links, CSS
I only have a total of 118 unique styles, but there are like 2 or 3 copies of the same style for each of them, resulting in having a large collection of dupes:
All my styles are imported from the Catppuccin userstyles collection.
Here I provide an export of my currently collection of duplicate styles:
stylus-2025-02-01.json
I don't know how to remove the dupes without doing manually going one by one. I already tried following the method described here, with no success.
The text was updated successfully, but these errors were encountered: