Skip to content

Add UI for editing ignores (fixes #502) - #721

Merged
calmh merged 5 commits into
syncthing:masterfrom
AudriusButkevicius:ignores
Sep 22, 2014
Merged

calmh merged 5 commits into
syncthing:masterfrom
AudriusButkevicius:ignores

Conversation

@AudriusButkevicius

Copy link
Copy Markdown
Member

Feel free to suggest better texts/messages, as I am usually pretty bad at it.

@AudriusButkevicius
AudriusButkevicius force-pushed the ignores branch 2 times, most recently from 4662b1f to 2e3fb2b Compare September 20, 2014 22:04
@marclaporte

Copy link
Copy Markdown
Member

+1 to a GUI for ignores.

About the syntax, Open Hub selected the robots.txt syntax for reasons explained in the blog post (See also discussion in the forums)
http://blog.openhub.net/2011/02/latest_updates_to_ignoring_files_and_directories/

Thanks!

@calmh

calmh commented Sep 21, 2014

Copy link
Copy Markdown
Member

Just starting to look at it, two things strike me. First, I think we should stick to JSON format in the REST interface here too, something like a map[string][]string{"ignores": []string{...}} object.

The second is I'm not sure about adding ignores by default. In principle it seems like a good idea to ignore crap files per default, but the effects are kind of nasty due to other stuff. For example, ignoring .DS_Store makes it tricky to actually delete a directory on Mac (it'll fail with "directory not empty"). (Maybe there should be a list of files we'll kill anyway when trying to remove a directory? But that's unrelated here.)

@AudriusButkevicius

Copy link
Copy Markdown
Member Author

I disagree with the JSON idea. It's like replacing file downloads with a JSON wrapper... We are retrieving and uploading the file exactly as its defined, what's the purpose of wrapping in as part of JSON?
Also, wrapping it up in JSON is not really giving any benefit, and adds extra work at both ends. (Turning an array into a object with an array, then parsing the object with an array, joining the strings and then the opposite going back).

The reason I proposed the "default ignores" is because btsync did it, and because its a nice way to define what the format for the ignores are.

I can remove the default ignores if you wish.

@calmh

calmh commented Sep 21, 2014

Copy link
Copy Markdown
Member

It's like replacing file downloads with a JSON wrapper... We are retrieving and uploading the file exactly as its defined, what's the purpose of wrapping in as part of JSON?

I disagree. :) We're not shuffling a file, we're shuffling an array of strings. If nothing else, it's a shorter way to do roughly the same amount of work. This

body, err := ioutil.ReadAll(r.Body)
if err != nil {
    http.Error(w, err.Error(), 500)
    return
}
r.Body.Close()

var lines []string
scanner := bufio.NewScanner(bytes.NewReader(body))
for scanner.Scan() {
    lines = append(lines, strings.TrimSpace(scanner.Text()))
}
err = m.SetIgnores(qs.Get("repo"), lines)

becomes just

var input map[string][]string
err = json.NewDecoder(r.Body).Decode(&input)
r.Body.Close()
if err != nil {
    http.Error(w, err.Error(), 500)
    return
}
err = m.SetIgnores(qs.Get("repo"), input["ignore"])

It would be even cleaner if we'd just serialized it as a []string, but I'll go with the earlier argument of holding the interface homogenous (with straight JSON objects).

The reason I proposed the "default ignores" is because btsync did it, and because its a nice way to define what the format for the ignores are.

I agree with this, and would have liked it in there. It's the sane thing to do. But I suspect that with the other stuff unfixed, it's going to cause more problems than it avoids. Basically, we just need to correctly handle deletes of non-empty directories (i.e. those containing ignored files) in a better way, that doesn't make the directory re-materialize on other nodes. This should be solved by my new-puller branch in some not too far away future, and then the default ignores will be painless.

@AudriusButkevicius

Copy link
Copy Markdown
Member Author

Updated

@calmh
calmh merged commit 709570a into syncthing:master Sep 22, 2014
@AudriusButkevicius
AudriusButkevicius deleted the ignores branch September 22, 2014 13:46
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jun 16, 2017
@syncthing syncthing locked and limited conversation to collaborators Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants