How are conflicts handled?

From @ulises on Tue Jul 26 2016 15:13:52 GMT+0000 (UTC)

If a node goes offline, a file is deleted in the node, and then it goes online again (netsplit or proper offline). What does the node do when it comes back online?

  • Propagate the delete
  • Get the file back from other nodes
  • Something else

IIUC in matrix conflicts are passed on to the clients, so I wonder how these are resolved (if at all) in IPFS.

Copied from original issue:

From @RichardLitt on Tue Jul 26 2016 15:15:59 GMT+0000 (UTC)

Edited slightly to make a cleaner title. Thank you!

From @flyingzumwalt on Tue Jul 26 2016 15:46:18 GMT+0000 (UTC)

This is a repetition of some info that’s elsewhere in the FAQ. We should gather some of it together for clarity.

Relevant Ideas about how IPFS Currently Works

  • Files don’t leave your machine until/unless a peer requests that file.
  • Files don’t enter your machine until/unless you request that file.
  • If you want a file to stay on your machine, you pin it
  • Garbage collection deletes any local IPFS files that you have not pinned.

When you write a file into IPFS on a node, it does the following:

  • Builds the DAG representing that file, storing that DAG locally
  • Tells peers that the new entry exists by writing the corresponding hashes and some metadata into the DHT

Deleting Stuff

Local Deletes

To “delete” a file locally,

  1. un-pin the file
  2. run garbage collection

This removes the file from your local IPFS.

(not allowed) Deleting Other People’s Copies

The IPFS protocol does not support deleting content from other people’s nodes. This is just like the web currently works – after someone “downloads” a file from your machine, they control that copy. If you want those peers to delete their copies, that’s an out-of-band conversation you need to have beyond the IPFS protocol. Some approaches: smart contracts, emails, phone calls, etc.

Answer to the Original Question

Given the scenario you describe, where a file is deleted from your node while it’s offline.

If nobody has ever pulled a copy of your file

If nobody has ever pulled a copy of your file, it’s gone.

If any peers have pulled copies of your file

If any peers have pulled copies of your file AND they still have those copies, meaning they have either pinned the file on their node or they have not yet garbage collected, then the content is still available on the network. Next time you request that content, you will be doing a regular request for content on the network. Your local node will look up the hash for that content in the DHT, find the peers who have copies of the file, and pull the file from those peers.

From @flyingzumwalt on Tue Jul 26 2016 15:58:30 GMT+0000 (UTC)

Thanks to @Kubuxu and @whyrusleeping for helping me write this answer.

I’m trying to follow the instructions here, but I can’t find any clear instructions on how to “run garbage collection”.

ipfs commands

doesn’t list anything called ‘delete’ or ‘garbage’ collect. Can someone tell me how to manually trigger garbage collection?

You want the ipfs repo gc command.