-
Notifications
You must be signed in to change notification settings - Fork 105
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
Multiple tilepaths splitted by ','. Hash based IDs of tilesets. Walking by tree with symlinks #92
Conversation
… (without splitter ':') also worked
I'm also rename |
some travis job are disconnected because job very long wait on queue =( |
@asmyasnikov Thanks for your PR! Good catch on the duplicate code between Help me understand your use case better - why is having multiple root directories better than having subdirectories within a single root directory? I understand the need to generate IDs to get around possibly duplicate directory names; however, my strong preference is that we rely on the filesystem to ensure uniqueness, and have close parity between the subdirectories / mbtiles filenames and the resulting service IDs. I found that we aren't handling symlinked subdirectories correctly, so I created #93 to track that. I think if we handled those properly, it would be possible for you to have multiple symlinked subdirectories for different collections of tilesets, provided that you assign each a unique symlink name within the directory passed to mbtileserver with the |
My hardware solution is a single board computer (aka RaspberryPi or Odroid). |
Not found place for share my Dockerfile. Print in this topic (may be help you)
I'm use busybox (lighter than alpine). My mbtileserver docker image for amd64 have only 17.1MB, for arm32v7 - 13MB |
@asmyasnikov thanks for the additional details. That is a really interesting use case; while we are happy that I'm assuming under your setup that it is possible to mount the flash drive to a directory name that is defined in advance? This seems like it would allow you to define 2 well-known source paths (one for the static tilesets and one for the optional ones) in such a way that they are unique, and avoid the need to generate IDs for them from a hash? Or taking that even further, it seems theoretically possible to define a single local directory that includes symlinked subdirectories - one to your static tilesets, and one to the root folder of the tilesets on the flash drive. In this case, you only need to know the mount directory of the flash drive to symlink it, not the directory structure on the flash drive, right? |
|
On single board computers only mbtileserver are unobtrusive instead tilemill, tilestash, mapnik and other WMTS. |
Thanks for the additional information. Limited support for symlinks on different filesystems is definitely something to consider in our approach here. At minimum, we'd have to do testing with #93 to make sure that there is decent support for symlink traversal across various filesystems. I would hope that the standard go library handles those cases correctly. The issues you describe with symlinks are certainly true as general cases, though for normal server-based environments, they could be entirely controlled prior to starting up For your users, is it possible to have a well-defined path that is required on their flash drive in order to support the use of optional tilesets? Plus well-defined instructions for how to organize their optional tilesets? It seems like those would help mitigate some of the potential shortcomings of you using symlinks locally to point to the optional tile directory on the flash drive. How are users consuming these tilesets? How will they discover what tilesets are available? Is the We're using named subdirectories in production, so it would be a bit challenging to migrate existing uses to a hash-based ID system. |
Further question: how is |
My devices do not nave GUI such as Gnome, KDE, Mate or other, using as real web-server. Users must connect to device by http from browser. User cannot run applications at its discretion. I proceed from the concept of "stupid user" (which don't understand bash, SSH and other utils) |
As solution of problem I may create different arg for slice of paths. --path arg (and TILE_PATH envvar) corresponds to base dir of tilesets and will be provide plain ids, tilesets from different arg with tilesets corresponds to hash IDs. All ids (plain and hash) will be present in |
Ok, so it sounds like in your case, the root directories of the tilesets are well-defined and known at the time I'd need help to identify sufficient cases of bad paths or filenames to make sure we handle that correctly, but that feels like a separate issue that we should address outside the context of this PR, since it affects the server in general. Given a root path(s), server should be able to find all valid Do you have examples of bad paths for filenames we can use for testing? Likewise, for valid paths and filenames, we need to be able to generate valid URLs to them. I'm not yet sure I like the idea of a separate argument that provides an alternative way of specifying tile directories and ID schemes, so please hold off on implementing that. Instead, I see the following decision points, which are related but not directly coupled:
|
Bad filenames I cannot get you. I need search and test all my realy and invented external storages. |
|
|
Ignore duplicate - wrong way. In two tilesets paths may be equal mbtiles file. For example, world.mbtiles, but different content (timestamps or other). Auto ignore cannot get from use needed map |
hashes will help to user for get needed map. |
You are controlling startup (if I understood your description above), so for your specific case you can always use the Can you please explain what you mean by this?
How are errors communicated back to the user about invalid tilesets from their flash drive? Based on your description, I see an important distinction between:
The first is about server stability, the second is about user interface. If users provide invalid paths / tilesets, ignore directions about how to name things, etc - what do they expect to happen? The server process should not crash, so other valid tilesets should still be available, but what about the invalid ones? |
but in this case I will use |
hashes creates from abspath and unique for equal filenames in different paths.
|
Users cannot view wrong tilesets and msgs about reasons. Yes, server must be a stable. In my solution wrong filenames and errors may see from |
Redundant file walk and appropriate error handling handled in ab7ae02 Which should also make server startup more robust even if there are errors scanning tileset directories. Per #94, I think we should use a URL-safe SHA1 for IDs instead of MD5. I have some opinions about how I'd like that API to look, so I'll try to take a first pass today. |
I was tryed sha1 yesterday. URLs was bad (some characters are not good for URLs) and was different length. For URLs hash must be with predefined alphabet (only readable characters). After this experience I was changed algorithm to md5 (URLs was also bad) and result was wrapped on hexify. URLs acquired readable view and fix length |
@asmyasnikov what do you think about splitting paths on |
this ok, not principially |
I wrote simple scanner for walk directory tree with symlinks (pushed to my repo). Filenames are ok. But paths with symlinks are not applied in service set. Because this paths need repeatedly wrap for good applying =( |
Task of symlinks are not easy =( |
multiple paths looks easier |
my last changes not break existing features, only refactoring (scanTilesets method and merge with resolving conflicts). scanTilesets make isolated code of walking by tree. Because in symlink case need call scanTilesets recursive and replace prefix of filepath |
|
was an attempt to escape out extra characters in path or filename, I didn't catch that it broke paths. Note: I'm still working on the branch Thanks for your work investigating symlinks, it sounds like those may not be the good option I was hoping for. Refactoring scan of tilesets given a base directory seems reasonable. Overall, I'd like to keep the interface of One option might be to allow variadic path arguments, but they can only be the last argument, which creates a less-than-ideal function signature func NewFromBaseDir(generateIDs bool, baseDirs ...string) (*ServiceSet, error) {
for _,baseDir:= range baseDirs {
...find tilesets, construct ids, and add to ServiceSet
}
...
} Lightweight proof of concept of this in Another option would be to provide a A further option would be to provide a new method that allows us to construct the |
@asmyasnikov I'm not sure what you mean by:
Do you mean the split on ','? |
Yes, I was code ',' yet =) |
Merge strategy in my branch already worked by default - new equal filepath replace old filepath in other base path. This is normal for me. First base dir - persistent, second base dir - removable. If removable media contains tileset with filename which equal with persistent tiles, persistent tileset will be forget. I was tested this case and it's ok. |
@asmyasnikov I'm having a hard time following some of your comments. When you say
Do you mean your PR here was looping over tilesets in both directories and adding them to the same Right now, the code does not warn you if you have multiple instances of the same ID, as up until previously that was not permitted because paths forced unique IDs. I think we should log an error message in that case, and preserve the first rather than the last tileset that has the duplicate ID. Using the |
You are write - error msg needed. The code takes the form of my initial PR =) |
Old single tilepath (without splitter ':') also worked