Commit 520359a
authored
fix(conflicts): Improve conflict finder regex (#181)
Improve the base regex in the conflicts finder, so that it supports filenames
without extension.
Reference: Syncthing's conflict filename generator
https://github.com/syncthing/syncthing/blob/43d826913f917b0f2c692f0ecf90823e2e0528d7/lib/model/folder_sendrecv.go#L2227
`return name[:len(name)-len(ext)] + time.Now().Format(".sync-conflict-20060102-150405-") + lastModBy + ext`
Changes:
- `.sync-` -> `\.sync`: properly escape this dot that is always present
in the conflict filename.
- `(-(?<device>[a-zA-Z0-9]+))?` -> `-(?<device>[a-zA-Z0-9]+)?`: the dash is
always present, even if there was no `lastModBy` device. Do not tag it as
optional.
- `(?<suffix>.*)` -> `(?<suffix>.*(?=\.))?`: This will match all the stuff
that other software could add before the extension and after the syncthing
conflict tag, by matching until the last `.` in the filename. This named
group should be optional
- `(?<extension>\..*)` -> `(?<extension>\..*)?`: Make extension optional1 parent 72fc996 commit 520359a
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
0 commit comments