vdirsyncer icon indicating copy to clipboard operation
vdirsyncer copied to clipboard

cli/discover: remove/add local collections if the remote collection is deleted/created

Open dilyanpalauzov opened this issue 4 years ago • 16 comments

This works when the destination backend is 'filesystem'.

-- add a new parameter to storage section: implicit = ["create", "delete"]

Changes cli/utils.py:save_status(): when data is None, remove the underlaying file.

dilyanpalauzov avatar Mar 07 '21 18:03 dilyanpalauzov

This pull request introduces 3 alerts when merging a38bb9625eea0703816c09e17e7a8294f2d43317 into a42906b0e82b8f9ef6a5d75394e8b50cb944ebb6 - view on LGTM.com

new alerts:

  • 2 for Except block handles 'BaseException'
  • 1 for Unused local variable

lgtm-com[bot] avatar Mar 07 '21 18:03 lgtm-com[bot]

This pull request introduces 2 alerts when merging 1c1cd3ffa3b4969ecdc389e8db797563c146caec into a42906b0e82b8f9ef6a5d75394e8b50cb944ebb6 - view on LGTM.com

new alerts:

  • 2 for Except block handles 'BaseException'

lgtm-com[bot] avatar Mar 07 '21 19:03 lgtm-com[bot]

The tests fail with

    raise DeadlineExceeded(runtime, self.settings.deadline)
        hypothesis.errors.DeadlineExceeded: Test took 227.47ms, which exceeds the deadline of 200.00ms

dilyanpalauzov avatar Apr 07 '21 08:04 dilyanpalauzov

Will this get eventually integrated upstream?

dilyanpalauzov avatar Jul 10 '21 13:07 dilyanpalauzov

@dilyanpalauzov Yup, sorry, just been busy, but the change makes sense. I'll deal with conflicts when I get a change :)

WhyNotHugo avatar Jul 15 '21 16:07 WhyNotHugo

Please elaborate what means “when I get a change”?

dilyanpalauzov avatar Jul 15 '21 17:07 dilyanpalauzov

Sorry, I meant "why I get a chance'. Meaning when I get a bit of free time to do the conflict resolution.

WhyNotHugo avatar Jul 16 '21 08:07 WhyNotHugo

I've rebased your branch onto master and resolved all conflicts.

I'm a bit uncertain about how this works when you have:

  • storage A with implicit = "create"
  • storage B with implicit = "delete"

If there's a collection present in B, but missing in A, should it be deleted from B, or created in A?

WhyNotHugo avatar Aug 04 '21 17:08 WhyNotHugo

I have not thought on this case. I would say, the collection shall be created.

Rationale: I do not know why this combination is good for. Preventing data deletion in this unclear use-case is a good approach, as long as nobody proposes something better.

dilyanpalauzov avatar Aug 04 '21 17:08 dilyanpalauzov

Let me know if there is anything from my side, which shall be done for this PR. I do not understand the code of vdirsyncer very good.

dilyanpalauzov avatar Aug 07 '21 05:08 dilyanpalauzov

• storage A with implicit = "create" • storage B with implicit = "delete"

If there's a collection present in B, but missing in A, should it be deleted from B, or created in A?

How about writing down,that the behaviour in this case is not defined.

dilyanpalauzov avatar Oct 17 '21 12:10 dilyanpalauzov

Is there anything I can do to help with this one? I'd love to have this feature as well.

samsonjs avatar Dec 29 '21 01:12 samsonjs

Perhaps only implicit creation should be allowed? That way there's never any accidental data loss, which is far worse than a zombie collection coming back from the dead. And there's no ambiguity about what to do in this scenario:

I'm a bit uncertain about how this works when you have:

storage A with implicit = "create" storage B with implicit = "delete"

If there's a collection present in B, but missing in A, should it be deleted from B, or created in A?

Selfishly, implicit creation is the only part of this that I actually need so if eliminating implicit deletion helps move this forward at all here then that suits me just fine 😄

samsonjs avatar Jun 30 '22 05:06 samsonjs

I need also implicit deletion.

dilyanpalauzov avatar Jun 30 '22 05:06 dilyanpalauzov

Fair enough. What about using conflict_resolution for this too? In the example scenario above there would be an error if none is specified, or if the config has "b wins" then the collection is deleted from A. I'm not sure if there's a good way use the diff command for this one though so maybe it could also produce an error when a command is configured.

I think that behaviour is actually pretty intuitive and most people would expect it to work that way.

samsonjs avatar Jun 30 '22 05:06 samsonjs

This pull request from me is stalled. I do use the changes on my system and it does work exactly as I want. I will appreciate any progress on this, but I am not going to modify the proposed changes.

dilyanpalauzov avatar Jun 30 '22 05:06 dilyanpalauzov