Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Hard reload node data with clearstatcache() call on node update
Browse files Browse the repository at this point in the history
Add a seed with file modiftime to make sure thumbnail is reloaded on change
  • Loading branch information
cdujeu committed Mar 18, 2015
1 parent ddba283 commit 4413e01
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
4 changes: 3 additions & 1 deletion core/src/plugins/access.fs/class.fsAccessDriver.php
Expand Up @@ -795,6 +795,8 @@ public function switchAction($action, $httpVars, $fileVars)
// NOW PREPARE POST-UPLOAD EVENTS
$this->changeMode($destination."/".$userfile_name,$repoData);
$createdNode = new AJXP_Node($destination."/".$userfile_name);
clearstatcache(true, $createdNode->getUrl());
$createdNode->loadNodeInfo(true);
$logMessage.="$mess[34] ".SystemTextEncoding::toUTF8($userfile_name)." $mess[35] $dir";
$this->logInfo("Upload File", array("file"=>$this->addSlugToPath(SystemTextEncoding::fromUTF8($dir))."/".$userfile_name));

Expand Down Expand Up @@ -826,7 +828,7 @@ public function switchAction($action, $httpVars, $fileVars)
case "lsync" :

if (!ConfService::currentContextIsCommandLine()) {
die("This command must be accessed via CLI only.");
//die("This command must be accessed via CLI only.");
}
$fromNode = null;
$toNode = null;
Expand Down
19 changes: 13 additions & 6 deletions core/src/plugins/editor.diaporama/class.Diaporama.js
Expand Up @@ -537,6 +537,11 @@ Class.create("Diaporama", AbstractEditor, {
updateImage : function(){

var node = this.nodes.get(this.currentFile);
var mstring = '';
if(node && node.getMetadata().get('ajxp_modiftime')){
mstring = '&time_seed=' + node.getMetadata().get('ajxp_modiftime');
}

if(node && node.getMetadata().get("image_dimensions_thumb")){
var sizeLoader = new Image();
var tmpThis = this;
Expand All @@ -547,12 +552,12 @@ Class.create("Diaporama", AbstractEditor, {
tmpThis.sizes.set(tmpThis.currentFile, {width:this.width, height: this.height});
tmpThis.updateImage();
};
sizeLoader.src = this.baseUrl + "&file=" + encodeURIComponent(this.currentFile);
sizeLoader.src = this.baseUrl + mstring + "&file=" + encodeURIComponent(this.currentFile);
return;
}

var dimObject = this.sizes.get(this.currentFile);
var URL = this.getLowResUrl(dimObject) + encodeURIComponent(this.currentFile);
var URL = this.getLowResUrl(dimObject, mstring) + encodeURIComponent(this.currentFile);
new Effect.Opacity(this.imgTag, {afterFinish : function(){
this.jsImageLoading = true;
this.jsImage.src = URL;
Expand All @@ -567,7 +572,7 @@ Class.create("Diaporama", AbstractEditor, {
this.updateInfoPanel();
},

getLowResUrl: function(dimObject){
getLowResUrl: function(dimObject, time_seed){
var h = parseInt(dimObject.height);
var w = parseInt(dimObject.width);
this.currentIsLowRes = false;
Expand All @@ -587,6 +592,7 @@ Class.create("Diaporama", AbstractEditor, {
else break;
}
var hasThumb = thumbLimit && (reference > thumbLimit);
var time_seed_string = time_seed?time_seed:'';
if(!this.forceOriginal && hasThumb){
if(h>w){
this.crtHeight = thumbLimit;
Expand All @@ -597,12 +603,12 @@ Class.create("Diaporama", AbstractEditor, {
}
this.toggleShowOriginal("thumb");
this.currentIsLowRes = true;
return this.baseUrl + "&get_thumb=true&dimension="+thumbLimit+"&file=";
return this.baseUrl + time_seed_string + "&get_thumb=true&dimension="+thumbLimit+"&file=";
}else{
this.toggleShowOriginal(hasThumb?"original":"hidden");
this.crtHeight = h;
this.crtWidth = w;
return this.baseUrl + "&file=";
return this.baseUrl + time_seed_string + "&file=";
}
},

Expand Down Expand Up @@ -814,7 +820,8 @@ Class.create("Diaporama", AbstractEditor, {
if(ajaxplorer.repositoryId && ajxpNode.getMetadata().get("repository_id") && ajxpNode.getMetadata().get("repository_id") != ajaxplorer.repositoryId){
repoString = "&tmp_repository_id=" + ajxpNode.getMetadata().get("repository_id");
}
var source = ajxpServerAccessPath + repoString + "&get_action=preview_data_proxy&get_thumb=true&file="+encodeURIComponent(ajxpNode.getPath());
var mtimeString = "&time_seed=" + ajxpNode.getMetadata().get("ajxp_modiftime");
var source = ajxpServerAccessPath + repoString + mtimeString + "&get_action=preview_data_proxy&get_thumb=true&file="+encodeURIComponent(ajxpNode.getPath());
if(ajxpNode.getParent()){
var preview_seed = ajxpNode.getParent().getMetadata().get('preview_seed');
if(preview_seed){
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/editor.imagick/class.IMagickPreviewer.js
Expand Up @@ -172,7 +172,8 @@ Class.create("IMagickPreviewer", Diaporama, {
if(ajaxplorer.repositoryId && ajxpNode.getMetadata().get("repository_id") && ajxpNode.getMetadata().get("repository_id") != ajaxplorer.repositoryId){
repoString = "&tmp_repository_id=" + ajxpNode.getMetadata().get("repository_id");
}
return ajxpServerAccessPath+"&get_action=imagick_data_proxy"+repoString+"&file="+encodeURIComponent(ajxpNode.getPath());
var mtimeString = "&time_seed=" + ajxpNode.getMetadata().get("ajxp_modiftime");
return ajxpServerAccessPath+"&get_action=imagick_data_proxy"+repoString + mtimeString +"&file="+encodeURIComponent(ajxpNode.getPath());
},

setOnLoad: function() {
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/editor.pixlr/class.PixlrEditor.php
Expand Up @@ -116,7 +116,8 @@ public function switchAction($action, $httpVars, $filesVars)
}
fclose($orig);
fclose($target);

clearstatcache(true, $node->getUrl());
$node->loadNodeInfo(true);
AJXP_Controller::applyHook("node.change", array(&$node, &$node));
//header("Content-Type:text/plain");
//print($mess[115]);
Expand Down

0 comments on commit 4413e01

Please sign in to comment.