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

@dblock => Allow a Fog::Storage uploader to be passed in for uploading of generated tiles rather than local storage #5

Merged
merged 1 commit into from
Oct 17, 2014

Conversation

mzikherman
Copy link
Collaborator

Will use this library with Gemini.

@dblock
Copy link
Owner

dblock commented Oct 16, 2014

This is pretty hacky. Lets use some OO? I'd like you to extract a class that implements the same interface to store files and make an implementation for local files and another for S3. So instead of destination or uploader the tiler should just take a storage instance. It won't need to know anything about S3 keys this way either.

You also need to update CHANGELOG and possibly README if you're going to expose this in the command line tool.

@tile_quality = options[:quality] || DEFAULT_QUALITY
@overwrite = options[:overwrite] || false
@destination = options[:destination] || File.join(Dir.pwd, "tiles")
@uploader = options[:uploader]
Copy link
Owner

Choose a reason for hiding this comment

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

This should be @storage = options[:storage] || FileStorage.new(@destination).

@mzikherman mzikherman force-pushed the uploader branch 2 times, most recently from f1812eb to 16bb574 Compare October 16, 2014 19:40
FileUtils.mkdir_p(current_level_dir)

current_level_storage_dir = @storage.storage_location(level)
@storage.mkdir(current_level_storage_dir)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no-op since S3 doesn't have directories, no need to create anything ahead of time, as long as the right key/prefix is used.

@mzikherman
Copy link
Collaborator Author

Updated @dblock . Thanks for the comment on making it more OO rather than just modifying the existing utility. I moved the logic of constructing the directory/filename of resultant files and storage of the files into the new classes, it definitely feels cleaner now.

raise "Output directory #{@destination} already exists!"
@overwrite ? Rails.logger.warn(msg) : raise(msg)
end
@storage.handle_overwrite_existing_files!
Copy link
Owner

Choose a reason for hiding this comment

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

This is something I would not sink into storage, the interface is basically "does the destination exist?", and if it doesn't, fail - it's weird that the failure is in the file storage itself.

The old condition body looks like a bug, and a bad copy-paste from some old code too - there's no such thing as msg, much less Rails.logger :)

raise "Output #{@destination} already exists!" if !@overwrite && storage.exists?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's what I thought! I was reading it like wtf, but kept it :(

@dblock
Copy link
Owner

dblock commented Oct 16, 2014

This is 99% there, see my comments.

Add a line to CHANGELOG too, please (create a "Next" section).

@mzikherman
Copy link
Collaborator Author

Amended once more, thanks again for the feedback.

@@ -1,3 +1,7 @@
### Next

* [#5](https://github.com/dblock/dzt/pull/5) Allow a Fog::Storage uploader to be passed in for uploading of generated tiles rather than local storage
Copy link
Owner

Choose a reason for hiding this comment

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

This is missing a link to you, - @.... See lines below.

@mzikherman
Copy link
Collaborator Author

Updated.

dblock added a commit that referenced this pull request Oct 17, 2014
@dblock => Allow a Fog::Storage uploader to be passed in for uploading of generated tiles rather than local storage
@dblock dblock merged commit 4091184 into dblock:master Oct 17, 2014
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.

None yet

2 participants