master
elf 2 years ago
parent 37091aef58
commit d72fcede10

@ -913,4 +913,39 @@ class ConsoleController extends Think {
$extra
);
}
public function unlinkSourceFile() {
$records = M('game_source', 'tab_')->select();
$sourceFiles = array_column($records, 'file_name');
$originalDir = ROOTTT . 'Uploads/Ios/original';
$files = $this->getFiles($originalDir);
foreach ($files as $file) {
if (!in_array($file, $sourceFiles)) {
echo 'move [' . $originalDir . '/' . $file . '] to [' . '/data/backup/sourceFile/original/' . $file . ']' . PHP_EOL;
// rename($originalDir . '/' . $file, '/data/backup/sourceFile/original/' . $file);
}
}
$sourceDir = ROOTTT . 'Uploads/SourcePack';
$files = $this->getFiles($sourceDir);
foreach ($files as $file) {
if (!in_array($file, $sourceFiles)) {
echo 'move [' . $sourceDir . '/' . $file . '] to [' . '/data/backup/sourceFile/' . $file . ']' . PHP_EOL;
// rename($sourceDir . '/' . $file, '/data/backup/sourceFile/' . $file);
}
}
}
private function getFiles($dir){
$mydir = dir($dir);
$files = [];
while($file = $mydir->read()){
if((is_dir("$dir/$file"))) {
} elseif($file !== "." && $file !== "..") {
$files[] = $file;
}
}
$mydir->close();
return $files;
}
}

Loading…
Cancel
Save