Editing .bitpocket/exclude results in unexpeced deletions & data loss
torfason opened this issue · 4 comments
When an exclusion line is removed from .bitpocket/exclude, the expected behavior would be to start syncing that file/directory. However, the actual behavior is that this file is deleted. The following script, as well as script output, illustrates the issue (using a fresh BitPocketMaster directory):
Script
mkdir BitPocket
cd BitPocket
bitpocket init user@host.domain.net /home/user/BitPocketMaster
bitpocket sync
bitpocket sync
echo content>file-1.txt
echo content>file-2.txt
bitpocket sync
echo content>file-excluded.txt
echo "/file-excluded.txt">.bitpocket/exclude
bitpocket sync
ll
rm .bitpocket/exclude
bitpocket sync
ll
Result
file-excluded.txt is gone, which is not the expected behavior, since it has never been deleted.
With output
[tmp]$ mkdir BitPocket
[tmp]$ cd BitPocket
[BitPocket]$ bitpocket init user@host.domain.net /home/user/BitPocketMaster
Initialized bitpocket directory at /home/user/tmp/BitPocket
Please have a look at the config file (.bitpocket/config)
[BitPocket]$ bitpocket sync
bitpocket started at Fri Jan 11 15:34:14 EST 2013.
Fetching changes from server
receiving incremental file list
.d..t...... ./
sent 31 bytes received 59 bytes 60.00 bytes/sec
total size is 0 speedup is 0.00
Pushing changes to server
sending incremental file list
sent 74 bytes received 12 bytes 57.33 bytes/sec
total size is 0 speedup is 0.00
[BitPocket]$ bitpocket sync
bitpocket started at Fri Jan 11 15:34:31 EST 2013.
Fetching changes from server
receiving incremental file list
sent 28 bytes received 56 bytes 56.00 bytes/sec
total size is 0 speedup is 0.00
Pushing changes to server
sending incremental file list
sent 74 bytes received 12 bytes 57.33 bytes/sec
total size is 0 speedup is 0.00
[BitPocket]$ echo content>file-1.txt
[BitPocket]$ echo content>file-2.txt
[BitPocket]$ bitpocket sync
bitpocket started at Fri Jan 11 15:34:49 EST 2013.
Fetching changes from server
receiving incremental file list
.d..t...... ./
sent 65 bytes received 59 bytes 82.67 bytes/sec
total size is 0 speedup is 0.00
Pushing changes to server
sending incremental file list
<f+++++++++ file-1.txt
<f+++++++++ file-2.txt
sent 208 bytes received 50 bytes 172.00 bytes/sec
total size is 16 speedup is 0.06
[BitPocket]$ echo content>file-excluded.txt
[BitPocket]$ echo "/file-excluded.txt">.bitpocket/exclude
[BitPocket]$ bitpocket sync
bitpocket started at Fri Jan 11 15:35:13 EST 2013.
Fetching changes from server
receiving incremental file list
.d..t...... ./
sent 79 bytes received 97 bytes 117.33 bytes/sec
total size is 16 speedup is 0.09
Pushing changes to server
sending incremental file list
sent 136 bytes received 12 bytes 98.67 bytes/sec
total size is 16 speedup is 0.11
[BitPocket]$ ll
total 3
-rw------- 1 mtorfason Domain Users 8 Jan 11 15:34 file-1.txt
-rw------- 1 mtorfason Domain Users 8 Jan 11 15:34 file-2.txt
-rw------- 1 mtorfason Domain Users 8 Jan 11 15:35 file-excluded.txt
[BitPocket]$ rm .bitpocket/exclude
[BitPocket]$
[BitPocket]$ bitpocket sync
bitpocket started at Fri Jan 11 15:35:38 EST 2013.
Fetching changes from server
receiving incremental file list
*deleting file-excluded.txt
sent 28 bytes received 94 bytes 81.33 bytes/sec
total size is 16 speedup is 0.13
Pushing changes to server
sending incremental file list
sent 112 bytes received 12 bytes 82.67 bytes/sec
total size is 16 speedup is 0.13
[BitPocket]$ ll
total 2
-rw------- 1 mtorfason Domain Users 8 Jan 11 15:34 file-1.txt
-rw------- 1 mtorfason Domain Users 8 Jan 11 15:34 file-2.txt
[BitPocket]$ # file-excluded.txt is gone, which is not the expected
[BitPocket]$ # behavior, since it has never been deleted.
I'm not familiar enough with bitpocket to completely understand that issue (#20), especially since I can't see a description of that, but perhaps that issue refers to the fact that an excluded file:
1: Ends up in .bitpocket/state/tree-current, but
2: Is not sent to the server on initial sync (because it's excluded), but
3: On syncing after changing exclude, it is observed as having once existed locally (because it's in tree-current), but not does not exist on master, and is therefore classified as having been deleted somewhere else.
That sounds convincing, and it also seems clear to me that the correct behavior would be that a file that is not sent to Master should also not be added to tree-current.
This is fixed in torfason/bitpocket@60dd63367e.
However, I'd recommend pulling the changes from torfason/bitpocket@bc67232bbf in that same repo instead of torfason/bitpocket@60dd63367e, since torfason/bitpocket@bc67232bbf has been much more extensively tested.
The fix described above was merged into sickill/bitpocket around a year ago, so this issue can be closed.