logoalt Hacker News

hurflmurfllast Thursday at 7:56 AM0 repliesview on HN

Fair question. Conflicts happen, which I'm fine with.

Realistically speaking, most files I have in my cloud are read-only. The most common file that I read-write on multiple devices is my keepass file, which supports conflict resolution (by merging changes) in clients.

Also used to happen when I tried editing some markdown notes using obsidian on PC, and then using text editor (or maybe obsidian again?) on android, but I eventually sort of gave up on that use-case. Editing my notes from my phone is sort of inconvenient anyway, so I mostly just create new short notes that I can later edit into some larger note, but honestly can't remember the last time this happened.

But yes, if not careful, you could run into your laptop overwriting the file when it comes online. In my case, it doesn't really happen, and when it does, Nextcloud will have the "overwritten version" saved, so I can always check what was overwritten and manually merge the changes.

P.S. If anyone wants to set this up, here's my nixos config for the service, feel free to comment on it:

  # don't forget to run `rclone config` beforehand
  # to create the "nextcloud:" remote
  # some day I may do this declaratively, but not today
  systemd.services.rclone-nextcloud-mount = {
    # Ensure the service starts after the network is up
    wantedBy = [ "multi-user.target" ];
    after = [ "network-online.target" ];
    requires = [ "network-online.target" ];

    # Service configuration
    serviceConfig = let
      ncDir = "/home/username/nextcloud";
      mountOptions = "--vfs-cache-mode full --dir-cache-time 1w --vfs-cache-max-age 1w";
    in {
      Type = "simple";
      ExecStartPre = "/run/current-system/sw/bin/mkdir -p ${ncDir}"; # Creates folder if didn't exist
      ExecStart = "${pkgs.rclone}/bin/rclone mount ${mountOptions} nextcloud: ${ncDir}"; # Mounts
      ExecStop = "/run/current-system/sw/bin/fusermount -u ${ncDir}"; # Dismounts
      Restart = "on-failure";
      RestartSec = "10s";
      User = "username";
      Group = "users";
      Environment = [ "PATH=/run/wrappers/bin/:$PATH" ];
    };
  };