Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
change --no-cache to --force, fix implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
moollaza committed Oct 29, 2014
1 parent 31ac1a1 commit 77f45be
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lib/App/DuckPAN/Cmd/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ use Config::INI;
use Data::Printer;
use Data::Dumper;

option no_cache => (
option force => (
is => 'ro',
lazy => 1,
short => 'f',
default => sub { 0 }
);

Expand Down Expand Up @@ -112,7 +113,7 @@ sub run {

print "\n\nHostname is: http://".$self->hostname if $self->verbose;
print "\n\nChecking for newest assets from: http://".$self->hostname."\n";
print "\n[CACHE DISABLED]. Forcing request for all assets...\n\n" if $self->verbose && $self->no_cache;
print "\n[CACHE DISABLED]. Forcing request for all assets...\n\n" if $self->verbose && $self->force;

# First we bootstrap the cache, copying all files from /share (dist_dir) into the
# cache. Then we get each file from given hostname (usually DuckDuckGo.com) and
Expand Down Expand Up @@ -331,17 +332,18 @@ sub get_sub_assets {
}
}

if ($self->no_cache) {
print "\nCaching turned off; assets will not be loaded.\n";
} else {
# Check if we need to request any new assets from hostname, otherwise use cached copies
foreach my $curr_asset ($self->page_js_files, $self->page_templates_files, @{$self->page_css_files_list}, $self->page_locales_files) {
my $file_name = $curr_asset->{internal};
if (path($self->app->cfg->cache_path, $file_name)->exists) {
print "\n$file_name already exists in cache -- no request made.\n" if $self->verbose;
} else {
$self->retrieve_and_cache($curr_asset, $from);
}
if ($self->force){
print "\nCache disable; Forcing request for every asset.\n";
}

# Check if we need to request any new assets from hostname, otherwise use cached copies
foreach my $curr_asset ($self->page_js_files, $self->page_templates_files, @{$self->page_css_files_list}, $self->page_locales_files) {
my $file_name = $curr_asset->{internal};

if (path($self->app->cfg->cache_path, $file_name)->exists && !$self->force) {
print "\n$file_name already exists in cache -- no request made.\n" if $self->verbose;
} else {
$self->retrieve_and_cache($curr_asset, $from);
}
}
}
Expand Down

0 comments on commit 77f45be

Please sign in to comment.