|
|
|
@ -156,16 +156,20 @@ eof;
@@ -156,16 +156,20 @@ eof;
|
|
|
|
|
$rootDir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory']; |
|
|
|
|
$rootDir = realpath($rootDir); |
|
|
|
|
|
|
|
|
|
if ($dirpath == $rootDir) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (strpos($dirpath, $rootDir) !== false) { |
|
|
|
|
$dirs = str_replace($rootDir, '', $dirpath); |
|
|
|
|
$dirs = preg_replace('/\/$/', '', $dirs); |
|
|
|
|
$arr = explode('/', $dirs); |
|
|
|
|
$num = count($arr); |
|
|
|
|
if ($num >= 2) { |
|
|
|
|
if ($num >= 1) { |
|
|
|
|
$left = array_slice($arr, 0, $num-1); |
|
|
|
|
return realpath( $rootDir . '/' . implode('/', $left) ); |
|
|
|
|
}else { |
|
|
|
|
return $rootDir; |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -195,9 +199,7 @@ eof;
@@ -195,9 +199,7 @@ eof;
|
|
|
|
|
|
|
|
|
|
//统计文件数量 |
|
|
|
|
$dirId = $scanner->getId($dirpath); |
|
|
|
|
$parentDir = $this->getParentDir($dirpath); |
|
|
|
|
$parentId = $scanner->getId($parentDir); |
|
|
|
|
$this->updateAllDirTreeCache($dirId, $parentId, $dirTree); |
|
|
|
|
$this->updateAllDirTreeCache($dirId, $dirpath, $dirTree, $scanner); |
|
|
|
|
|
|
|
|
|
$scanResults = $scanner->getScanResults(); |
|
|
|
|
echo 'Total directories or files: ' . count($scanResults); |
|
|
|
@ -434,7 +436,7 @@ eof;
@@ -434,7 +436,7 @@ eof;
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function updateAllDirTreeCache($dirId, $parentId, $dirTree) { |
|
|
|
|
protected function updateAllDirTreeCache($dirId, $dirpath, $dirTree, $scanner) { |
|
|
|
|
$cacheKey = $this->allDirTreeCacheKey; |
|
|
|
|
$cacheData = Common::getCache($cacheKey); |
|
|
|
|
if (empty($cacheData)) { |
|
|
|
@ -478,25 +480,33 @@ eof;
@@ -478,25 +480,33 @@ eof;
|
|
|
|
|
$cacheData[$dirId]['audio_total'] = $audioNum; |
|
|
|
|
echo "File total: {$dirId}: image {$imgNum}, video {$videoNum}, audio {$audioNum}\n"; |
|
|
|
|
|
|
|
|
|
//更新父目录数据 |
|
|
|
|
if (!empty($cacheData[$parentId])) { |
|
|
|
|
if (isset($cacheData[$parentId]['image_total'])) { |
|
|
|
|
$cacheData[$parentId]['image_total'] += $imgNum; |
|
|
|
|
}else { |
|
|
|
|
$cacheData[$parentId]['image_total'] = $imgNum; |
|
|
|
|
} |
|
|
|
|
//更新所有父目录数据 |
|
|
|
|
$parentDir = $this->getParentDir($dirpath); |
|
|
|
|
while (!empty($parentDir)) { |
|
|
|
|
//echo "{$dirpath} => {$parentDir}\n"; |
|
|
|
|
$parentId = $scanner->getId($parentDir); |
|
|
|
|
if (!empty($cacheData[$parentId])) { |
|
|
|
|
if (isset($cacheData[$parentId]['image_total'])) { |
|
|
|
|
$cacheData[$parentId]['image_total'] += $imgNum; |
|
|
|
|
}else { |
|
|
|
|
$cacheData[$parentId]['image_total'] = $imgNum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($cacheData[$parentId]['video_total'])) { |
|
|
|
|
$cacheData[$parentId]['video_total'] += $videoNum; |
|
|
|
|
}else { |
|
|
|
|
$cacheData[$parentId]['video_total'] = $videoNum; |
|
|
|
|
} |
|
|
|
|
if (isset($cacheData[$parentId]['video_total'])) { |
|
|
|
|
$cacheData[$parentId]['video_total'] += $videoNum; |
|
|
|
|
}else { |
|
|
|
|
$cacheData[$parentId]['video_total'] = $videoNum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($cacheData[$parentId]['audio_total'])) { |
|
|
|
|
$cacheData[$parentId]['audio_total'] += $audioNum; |
|
|
|
|
}else { |
|
|
|
|
$cacheData[$parentId]['audio_total'] = $audioNum; |
|
|
|
|
if (isset($cacheData[$parentId]['audio_total'])) { |
|
|
|
|
$cacheData[$parentId]['audio_total'] += $audioNum; |
|
|
|
|
}else { |
|
|
|
|
$cacheData[$parentId]['audio_total'] = $audioNum; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$dirpath = $parentDir; |
|
|
|
|
$parentDir = $this->getParentDir($dirpath); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Common::setCache($cacheKey, $cacheData); |
|
|
|
|