Skip to content

Commit

Permalink
NEPT-1530: Implement file flushing.
Browse files Browse the repository at this point in the history
  • Loading branch information
EC2 Default User committed Jul 23, 2019
1 parent 27fca8b commit 6828579
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions nexteuropa_varnish.module
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,21 @@ function nexteuropa_varnish_node_delete($node) {
}
}

/**
* Implements hook_file_delete().
*/
function nexteuropa_varnish_file_delete($file) {
$scheme = file_uri_scheme($file->uri);

if ($scheme !== FALSE && file_stream_wrapper_valid_scheme($scheme) === TRUE) {
// Get path on filesystem.
$wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
_nexteuropa_varnish_purge_paths(array(
'escaped_alias' => preg_quote($wrapper->getDirectoryPath($file) . '/' . $file->filename, '/'),
));
}
}

/**
* Implements hook_path_delete().
*/
Expand All @@ -288,14 +303,15 @@ function nexteuropa_varnish_path_delete($path) {
}

$node = menu_get_object('node', 1, $path['source']);
$is_file = strpos($path['source'], 'file/');

// Its a node path.
if (empty($node)) {
// Has to be a node or file path.
if ($node === NULL && $is_file === FALSE) {
return;
}

// No rule defined for the node: Ignore the rest of the process.
if (!nexteuropa_varnish_node_has_rules($node)) {
if ($node !== NULL && nexteuropa_varnish_node_has_rules($node) === FALSE) {
return;
}

Expand Down

0 comments on commit 6828579

Please sign in to comment.