class Qwik::SiteBackup
Constants
- TAR_CMD
Attributes
archive_path[R]
tmpfile_path[R]
Public Class Methods
command_exist?()
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 106 def self.command_exist? TAR_CMD.path.executable? end
new(site, config)
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 110 def initialize(site, config) @site = site @config = config @archive_path = site.cache_path + "#{@site.sitename}.tgz" @tmpfile_path = site.cache_path + "sitebackup.tmp" end
Public Instance Methods
_archive_mtime()
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 123 def _archive_mtime result = nil result = @archive_path.mtime if @archive_path.exist? return result end
_generate()
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 174 def _generate cleanup result = invoke(command) if result == :success && @tmpfile_path.exist? @tmpfile_path.rename(@archive_path) else @tmpfile_path.unlink if @tmpfile_path.exist? end end
_site_lastmod()
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 119 def _site_lastmod @site.lastmod_of_all end
_tmpfile_mtime()
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 129 def _tmpfile_mtime result = nil result = @tmpfile_path.mtime if @tmpfile_path.exist? return result end
cleanup()
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 190 def cleanup @tmpfile_path.unlink if @tmpfile_path.exist? @archive_path.unlink if @archive_path.exist? end
command()
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 161 def command "#{TAR_CMD} zcf #{@tmpfile_path} -C #{@config.sites_dir} " + "--exclude .cache --exclude .svn -h #{@site.sitename}" end
do_concurrent() { || ... }
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 184 def do_concurrent Thread.new { yield } end
generate()
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 166 def generate if defined?($test) && $test _generate else do_concurrent { _generate } end end
generating?(site_lastmod = _site_lastmod, archive_mtime = _archive_mtime, tmpfile_mtime = _tmpfile_mtime)
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 145 def generating?(site_lastmod = _site_lastmod, archive_mtime = _archive_mtime, tmpfile_mtime = _tmpfile_mtime) # explicit arguments for test return false if tmpfile_mtime.nil? if archive_mtime.nil? tmpfile_mtime > site_lastmod else tmpfile_mtime >= archive_mtime && tmpfile_mtime > site_lastmod end end
invoke(cmd)
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 155 def invoke(cmd) system(cmd) child_process = $? child_process.exitstatus == 0 ? :success : :failure end
latest?(site_lastmod = _site_lastmod, archive_mtime = _archive_mtime, tmpfile_mtime = _tmpfile_mtime)
click to toggle source
# File vendor/qwik/lib/qwik/act-sitebackup.rb, line 135 def latest?(site_lastmod = _site_lastmod, archive_mtime = _archive_mtime, tmpfile_mtime = _tmpfile_mtime) # explicit arguments for test return false if archive_mtime.nil? if tmpfile_mtime.nil? archive_mtime >= site_lastmod else archive_mtime >= site_lastmod && archive_mtime > tmpfile_mtime end end