Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Override cache for web hook inflate #76

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/App/KSP_CKAN/Tools/NetKAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ has 'file' => ( is => 'ro', required => 1 );
has 'ckan_meta' => ( is => 'ro', required => 1, isa => $Meta );
has 'status' => ( is => 'rw', required => 1, isa => $Status );
has 'rescan' => ( is => 'ro', default => sub { 1 } );
has 'overwrite' => ( is => 'ro', default => sub { 0 } );
has 'token' => ( is => 'ro', lazy => 1, builder => 1 );
has 'netkan' => ( is => 'ro', lazy => 1, builder => 1 );
has 'cache' => ( is => 'ro', lazy => 1, builder => 1 );
Expand Down Expand Up @@ -96,11 +97,13 @@ method _build__output {
}

method _build__cli {
if ($self->token) {
return $self->netkan." --outputdir=".$self->_output." --cachedir=".$self->_cache." --github-token=".$self->token." ".$self->file;
} else {
return $self->netkan." --outputdir=".$self->_output." --cachedir=".$self->_cache." ".$self->file;
}
my @opts = (
'--outputdir=' . $self->_output,
'--cachedir=' . $self->_cache,
);
push @opts, '--github-token=' . $self->token if $self->token;
push @opts, '--overwrite-cache' if $self->overwrite;
return join(' ', $self->netkan, @opts, $self->file);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really neat, I like it.


method _build_cache {
Expand Down Expand Up @@ -172,13 +175,13 @@ method _commit($file) {
}

if ($self->is_debug()) {
$self->debug("$changed would have been commited");
$self->debug("$changed would have been committed");
$self->ckan_meta->reset(file => $file);
return 0;
}

if ( ! $self->_netkan_metadata->staging ) {
$self->info("Commiting $changed");
$self->info("Committing $changed");
$self->ckan_meta->commit(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, thank you for the spelling fixes ☺️

file => $file,
message => "NetKAN generated mods - $changed",
Expand Down
1 change: 1 addition & 0 deletions lib/App/KSP_CKAN/WebHooks/InflateNetKAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ method inflate($identifiers) {
ckan_meta => $self->_CKAN_meta,
status => $self->_status,
rescan => 1,
overwrite => 1,
);
$netkan->inflate;
}
Expand Down