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

Commit 783e094

Browse files
committed
Fix 2G limitation on windows in many places ( do not use filesize directly )
1 parent ed6e001 commit 783e094

File tree

8 files changed

+52
-10
lines changed

8 files changed

+52
-10
lines changed

core/src/plugins/access.fs/class.fsAccessDriver.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public function switchAction($action, $httpVars, $fileVars)
378378
$tmpFNAME = $this->urlBase.$dir."/".str_replace(".zip", ".tmp", $localName);
379379
copy($file, $tmpFNAME);
380380
try {
381-
AJXP_Controller::applyHook("node.before_create", array(new AJXP_Node($tmpFNAME), filesize($tmpFNAME)));
381+
AJXP_Controller::applyHook("node.before_create", array(new AJXP_Node($tmpFNAME), $this->filesystemFileSize($tmpFNAME)));
382382
} catch (Exception $e) {
383383
@unlink($tmpFNAME);
384384
throw $e;
@@ -397,6 +397,7 @@ public function switchAction($action, $httpVars, $fileVars)
397397
header("Content-type:application/json");
398398
if($selection->isUnique()){
399399
$stat = @stat($this->urlBase.$selection->getUniqueFile());
400+
$this->filesystemFileSize(null, $stat);
400401
if (!$stat) {
401402
print '{}';
402403
} else {
@@ -407,6 +408,7 @@ public function switchAction($action, $httpVars, $fileVars)
407408
print '{';
408409
foreach($files as $index => $path){
409410
$stat = @stat($this->urlBase.$path);
411+
$this->filesystemFileSize(null, $stat);
410412
if(!$stat) $stat = '{}';
411413
else $stat = json_encode($stat);
412414
print json_encode($path).':'.$stat . (($index < count($files) -1) ? "," : "");
@@ -1548,10 +1550,14 @@ public function date_modif($file)
15481550
return $tmp;// date("d,m L Y H:i:s",$tmp);
15491551
}
15501552

1551-
public function filesystemFileSize($filePath)
1553+
public function filesystemFileSize($filePath, &$stat = null)
15521554
{
15531555
$bytesize = "-";
1554-
$bytesize = @filesize($filePath);
1556+
if($stat != null && is_array($stat)){
1557+
$bytesize = $stat[7];
1558+
}else{
1559+
$bytesize = @filesize($filePath);
1560+
}
15551561
if (method_exists($this->wrapperClassName, "getLastRealSize")) {
15561562
$last = call_user_func(array($this->wrapperClassName, "getLastRealSize"));
15571563
if ($last !== false) {
@@ -1561,7 +1567,9 @@ public function filesystemFileSize($filePath)
15611567
if ($bytesize < 0) {
15621568
$bytesize = sprintf("%u", $bytesize);
15631569
}
1564-
1570+
if($stat != null && is_array($stat)){
1571+
$stat["size"] = $stat[7] = $bytesize;
1572+
}
15651573
return $bytesize;
15661574
}
15671575

core/src/plugins/core.access/class.AbstractAccessDriver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ protected function copyOrMoveFile($destDir, $srcFile, &$error, &$success, $move
209209
return ;
210210
}
211211
if (!$move) {
212-
AJXP_Controller::applyHook("node.before_create", array(new AJXP_Node($destFile), filesize($realSrcFile)));
212+
if(method_exists($this, "filesystemFileSize")) $size = $this->filesystemFileSize($realSrcFile);
213+
else $size = filesize($realSrcFile);
214+
AJXP_Controller::applyHook("node.before_create", array(new AJXP_Node($destFile), $size));
213215
}
214216
if (dirname($realSrcFile)==dirname($destFile)) {
215217
if ($move) {

core/src/plugins/editor.audio/class.AudioPreviewer.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,21 @@ public function switchAction($action, $httpVars, $postProcessData)
6464
$cType = "audio/".array_pop(explode(".", $file));
6565

6666
$localName = basename($file);
67+
$node = new AJXP_Node($destStreamURL.$file);
68+
if(method_exists($node->getDriver(), "filesystemFileSize")){
69+
$size = $node->getDriver()->filesystemFileSize($node->getUrl());
70+
}else{
71+
$size = filesize($node->getUrl());
72+
}
6773

6874
header("Content-Type: ".$cType."; name=\"".$localName."\"");
69-
header("Content-Length: ".filesize($destStreamURL.$file));
75+
header("Content-Length: ".$size);
7076

7177
$stream = fopen("php://output", "a");
7278
call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL.$file, $stream);
7379
fflush($stream);
7480
fclose($stream);
7581

76-
$node = new AJXP_Node($destStreamURL.$file);
7782
AJXP_Controller::applyHook("node.read", array($node));
7883
$this->logInfo('Preview', 'Read content of '.$node->getUrl());
7984
//exit(1);

core/src/plugins/editor.browser/class.FileMimeSender.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ public function switchAction($action, $httpVars, $filesVars)
6161
return false;
6262
}
6363

64-
$filesize = filesize($destStreamURL . $file);
64+
$node = new AJXP_Node($destStreamURL.$file);
65+
if(method_exists($node->getDriver(), "filesystemFileSize")){
66+
$filesize = $node->getDriver()->filesystemFileSize($node->getUrl());
67+
}else{
68+
$filesize = filesize($node->getUrl());
69+
}
6570
$fp = fopen($destStreamURL . $file, "rb");
6671
$fileMime = "application/octet-stream";
6772

core/src/plugins/editor.video/class.VideoReader.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ public function switchAction($action, $httpVars, $filesVars)
4747
$file = $selection->getUniqueFile();
4848
$node = new AJXP_Node($destStreamURL.$file);
4949
session_write_close();
50-
$filesize = filesize($destStreamURL.$file);
50+
if(method_exists($node->getDriver(), "filesystemFileSize")){
51+
$filesize = $node->getDriver()->filesystemFileSize($node->getUrl());
52+
}else{
53+
$filesize = filesize($node->getUrl());
54+
}
5155
$filename = $destStreamURL.$file;
5256

5357
//$fp = fopen($destStreamURL.$file, "r");

core/src/plugins/meta.filehasher/class.FileHasher.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ public function switchActions($actionName, $httpVars, $fileVars)
194194
if ($selection->isUnique()) {
195195
$node = $selection->getUniqueNode($this->accessDriver);
196196
$stat = @stat($node->getUrl());
197+
if(method_exists($this->accessDriver, "filesystemFileSize")){
198+
$this->accessDriver->filesystemFileSize(null, $stat);
199+
}
197200
if (!$stat) {
198201
print '{}';
199202
} else {
@@ -221,6 +224,9 @@ public function switchActions($actionName, $httpVars, $fileVars)
221224
foreach ($files as $index => $path) {
222225
$node = new AJXP_Node($destStreamURL.$path);
223226
$stat = @stat($destStreamURL.$path);
227+
if(method_exists($this->accessDriver, "filesystemFileSize")){
228+
$this->accessDriver->filesystemFileSize(null, $stat);
229+
}
224230
if(!$stat) $stat = '{}';
225231
else {
226232
if(!is_dir($node->getUrl())) $hash = $this->getFileHash($node);

core/src/plugins/meta.syncable/class.ChangesTracker.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false
458458
} else if ($oldNode == null || $copy) {
459459
// CREATE
460460
$stat = stat($newNode->getUrl());
461+
if(method_exists($newNode->getDriver(), "filesystemFileSize")){
462+
$newNode->getDriver()->filesystemFileSize(null, $stat);
463+
}
461464
$newNode->setLeaf(!($stat['mode'] & 040000));
462465
$this->logDebug('INSERT', $newNode->getUrl());
463466
dibi::query("INSERT INTO [ajxp_index]", array(
@@ -473,6 +476,9 @@ public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false
473476
// CONTENT CHANGE
474477
clearstatcache();
475478
$stat = stat($newNode->getUrl());
479+
if(method_exists($newNode->getDriver(), "filesystemFileSize")){
480+
$newNode->getDriver()->filesystemFileSize(null, $stat);
481+
}
476482
$this->logDebug("Content changed", "current stat size is : " . $stat["size"]);
477483
$this->logDebug('UPDATE CONTENT', $newNode->getUrl());
478484
dibi::query("UPDATE [ajxp_index] SET ", array(

core/src/plugins/uploader.http/class.HttpDownloader.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ public function switchAction($action, $httpVars, $fileVars)
161161
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
162162
header("text/plain");
163163
if (is_file($destStreamURL.$file)) {
164-
echo filesize($destStreamURL.$file);
164+
$node = new AJXP_Node($destStreamURL.$file);
165+
if(method_exists($node->getDriver(), "filesystemFileSize")){
166+
$filesize = $node->getDriver()->filesystemFileSize($node->getUrl());
167+
}else{
168+
$filesize = filesize($node->getUrl());
169+
}
170+
echo $filesize;
165171
} else {
166172
echo "stop";
167173
}

0 commit comments

Comments
 (0)