Skip to content

Commit

Permalink
Fixed how remote/local files are compared, thus allowing updating fil…
Browse files Browse the repository at this point in the history
…es that have spaces or non-ascii characters.
  • Loading branch information
mikkpr committed Dec 22, 2015
1 parent 4b3bdad commit 67417ad
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/voog/dtk/filemanager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ class FileManager

BOILERPLATE_URL = '[email protected]:Edicy/design-boilerplate.git'

ASSET_FOLDER_MAP = {
'image' => 'images',
'stylesheet' => 'stylesheets',
'javascript' => 'javascripts',
'font' => 'assets',
'unknown' => 'assets'
}

def initialize(client, opts = {})
@client = client
@silent = opts.fetch(:silent, false)
Expand Down Expand Up @@ -447,16 +455,8 @@ def create_asset(asset = nil)
&& asset.respond_to?(:asset_type) \
&& (asset.respond_to?(:public_url) || asset.respond_to?(:data))

folder_names = {
'image' => 'images',
'stylesheet' => 'stylesheets',
'javascript' => 'javascripts',
'font' => 'assets',
'unknown' => 'assets'
}

if valid
folder = folder_names.fetch(asset.asset_type, 'assets')
folder = ASSET_FOLDER_MAP.fetch(asset.asset_type, 'assets')

Dir.mkdir(folder) unless Dir.exist?(folder)
Dir.chdir(folder)
Expand Down Expand Up @@ -665,7 +665,8 @@ def layout_id_map(layouts = nil)
def layout_asset_id_map(assets=nil)
assets ||= get_layout_assets
assets.inject(Hash.new) do |memo, a|
memo[a.public_url.gsub("http://#{@client.host}/", '')] = a.id
filename = "#{ASSET_FOLDER_MAP.fetch(a.asset_type, 'assets')}/#{a.filename}"
memo[filename] = a.id
memo
end
end
Expand Down

0 comments on commit 67417ad

Please sign in to comment.