Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow modtime zero value #40

Closed
wants to merge 1 commit into from
Closed

Allow modtime zero value #40

wants to merge 1 commit into from

Conversation

ghostsquad
Copy link

This prevents the vfsdata.go file from changing if the only
thing that has changed is the file modtime.

Resolves #26

This prevents the vfsdata.go file from changing if the only
thing that has changed is the file modtime.

Resolves #26
@dmitshur
Copy link
Member

dmitshur commented Jan 4, 2018

Sorry about the delay.

Thank you for the PR, but I prefer not to merge this. I think this functionality can and should be achieved orthogonally—it doesn't need to be built into vfsgen.

More specifically, it can be achieved by creating a passthrough http.FileSystem wrapper implementation, one that makes no changes to the input filesystem, except it strips all modtimes to be zero:

// ZeroModTimeFileSystem is an http.FileSystem wrapper.
// It exposes a filesystem exactly like Source, except
// all file modification times are changed to zero.
type ZeroModTimeFileSystem struct {
	Source http.FileSystem
}

func (fs ZeroModTimeFileSystem) Open(name string) (http.File, error) {
	f, err := fs.Source.Open(name)
	return file{f}, err
}

type file struct {
	http.File
}

func (f file) Stat() (os.FileInfo, error) {
	fi, err := f.File.Stat()
	return fileInfo{fi}, err
}

type fileInfo struct {
	os.FileInfo
}

func (fi fileInfo) ModTime() time.Time { return time.Time{} }

@dmitshur dmitshur closed this Jan 4, 2018
@ghostsquad
Copy link
Author

ghostsquad commented Jan 5, 2018 via email

@ghostsquad ghostsquad deleted the feature/allow-for-zero-modtime branch January 5, 2018 07:50
@dmitshur dmitshur mentioned this pull request Sep 26, 2018
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.

2 participants