Skip to content

Adds local filesystem support - #13

Merged
mholt merged 12 commits into
sourcegraph:masterfrom
emersion:fs
Aug 18, 2016
Merged

Adds local filesystem support#13
mholt merged 12 commits into
sourcegraph:masterfrom
emersion:fs

Conversation

@emersion

@emersion emersion commented Aug 13, 2016

Copy link
Copy Markdown
Contributor
  • Go storage
  • JS storage
  • Go tests

Fixes #6

@mholt

mholt commented Aug 13, 2016

Copy link
Copy Markdown
Contributor

Nice! Will start taking a look at this soon, maybe after the weekend. When it looks good and has tests, we can merge it in.

Comment thread fs.go Outdated
// The path to the directory where check files will be stored.
Dir string `json:"dir"`
// The URL corresponding to fs.Dir.
Url string `json:"url"`

@dmitshur dmitshur Aug 13, 2016

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread fs.go

err = json.NewDecoder(f).Decode(&index)
return
}

@mholt mholt Aug 18, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a matter of style, I would prefer not to have named returns here, and instead start the function with index := make(map[string]int64). Even though the function is small, I think the explicit returns are a little easier to follow, especially since you have to make the map anyway.

@mholt

mholt commented Aug 18, 2016

Copy link
Copy Markdown
Contributor

I think the CI tests are broken - @beyang, somebody want to take a look at that sometime? 😄

@mholt

mholt commented Aug 18, 2016

Copy link
Copy Markdown
Contributor

This PR is looking pretty good except for the html file change. Thanks for working on it, @emersion!

@emersion

emersion commented Aug 18, 2016

Copy link
Copy Markdown
Contributor Author

All right, fixed all issues!

The build is failing because there is no .travis.yml file so Travis tries to build a Ruby project. To fix it, just add a basic .travis.yml with language: go.

Comment thread fs.go
}

// Add new file to index
index[name] = time.Now().UnixNano()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be the same filename that you used above in os.Create? name is retrieved from GenerateFilename() but you use a potentially different time value here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index contains both filenames and their timestamp, which is helpful because we don't need to parse filenames anymore. Since filenames are just informative, I though having a slightly different timestamp wouldn't matter too much...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, thanks for clarifying.

@mholt

mholt commented Aug 18, 2016

Copy link
Copy Markdown
Contributor

Awesome! Thank you @emersion!!

@mholt
mholt merged commit 621bfab into sourcegraph:master Aug 18, 2016
@emersion
emersion deleted the fs branch August 18, 2016 22:08
@emersion

Copy link
Copy Markdown
Contributor Author

Yay! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants