Skip to content

Commit

Permalink
should run location sync with specific vagrant sub commands only to i…
Browse files Browse the repository at this point in the history
…mprove responsiveness teracyhq#531
  • Loading branch information
phuonglm committed Nov 15, 2018
1 parent 688ff94 commit 1ff2961
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/teracy-dev/extension/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def install(extensions)
extensions.each do |extension|
validate_dependencies(extension, extention_manifest_list) if Util.true?(extension['enabled'])
end

timer_end = Time.now
@logger.debug("installation finished in #{timer_end - timer_start}s of extensions: #{extensions}")
end
Expand All @@ -52,13 +51,20 @@ def sync(extension)
"path" => path
})
sync_existing = extension['path']['lookup'] == DEFAULT_EXTENSION_LOOKUP_PATH

Location::Manager.sync(extension['location'], sync_existing)

end

def validate(extension)
return unless Util.true?(extension['enabled'])

manifest = Manager.manifest(extension)
begin
manifest = Manager.manifest(extension)
rescue Errno::ENOENT
@logger.error("manifest for extension #{extension['path']['extension']} not found, seem that you haven't synced all the required extensions. Please run vagrant <status|up|reload> to sync them first")
abort
end

if !Util.exist?(manifest['name']) or !Util.exist?(manifest['version'])
@logger.error("The extension manifest's name and version must be defined: #{manifest}, #{extension}")
Expand Down
9 changes: 8 additions & 1 deletion lib/teracy-dev/location/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ class Manager
@@logger = TeracyDev::Logging.logger_for(self)

# return true if sync action is carried out, otherwise, return false
def self.sync(location, sync_existing = true)
def self.sync(location, sync_existing = true, force = false)
updated = false
timer_start = Time.now
if !force && !cmdRequireSync?
return false
end
@@synch_list.each do |synch|
if synch.sync(location, sync_existing) == true
updated = true
Expand All @@ -21,6 +24,10 @@ def self.sync(location, sync_existing = true)
@@logger.debug("sync finished in #{timer_end - timer_start}s with updated: #{updated}, location: #{location}")
updated
end

def self.cmdRequireSync?
return ARGV.include?('up') || ARGV.include?('status') || ARGV.include?('reload')
end
end
end
end

0 comments on commit 1ff2961

Please sign in to comment.