-
Notifications
You must be signed in to change notification settings - Fork 25
Conversation
3a95fa2
to
99d0235
Compare
Hey @slimsag Here's how automatic re-indexing works at the moment:
Whenever the user stars the server using
I haven't implemented partial re-indexing in this PR. I'm planning to cover it in another PR. Please review this one and suggest changes. Please note that Go isn't my first language. So I'm not aware of all the best practices and might have made some mistakes (esp. related to error handling and channels). So please be careful with the review :) |
cmd/doctree/util.go
Outdated
// | ||
// Reference: https://unix.stackexchange.com/questions/35832/how-do-i-get-the-md5-sum-of-a-directorys-contents-as-one-sum | ||
func GetDirHash(dir string) string { | ||
tarCmd := exec.Command("tar", "-cf", "-", dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be OK for now, but we'll need to come up with something smarter than this I think. I'm not totally sure I follow the needed for a directory hash, maybe you can explain the idea behind that a bit more for me?
The problem with this is:
tar
isn't available on Windows, might not be available in Docker images, etc. Not nice to depend on an external tool in general- It can be quite slow - I have a large project that this takes almost a minute to complete on:
$ time sh -c 'tar -cf - . | md5sum'
cd434e78961999ed1a7e56cfcd29cdf7 -
real 0m57.865s
user 0m14.312s
sys 0m24.263s
May be good enough for now, though! Happy to land this as-is and revisit the idea later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Will try to look for something better than this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
additionally I'm unsure if it is required for tar to have deterministic output, ie does it sort directory entries before adding them? It may just rely on the order of readdir which can change even if the underlying files have not changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really great, thanks for working on this! I'm very excited to have this functionality :D
I left some suggestions & questions inline, but looks great to me otherwise!
Apart from your suggestions, I also did the following:
|
Also ran `go mod tidy`
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Nice work! I've added an Some notes for myself to follow up on later:
|
permission to do so by an employer or client I am producing work for whom has this right.