<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
//use App\Services\FileService;
|
|
use App\Services\GooglePhotoSyncService;
|
|
|
|
//use App\Services\LiveStreamService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class TestCommand extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'test:all';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
// $service = new GooglePhotoSyncService();
|
|
// $service->syncDBToRedis();exit;
|
|
// $service->insertMappings();exit;
|
|
// $service->syncImageFiles();
|
|
// exit;
|
|
$dir = "/Volumes/desktop-5rv69tq/oPcSync/bilibili/bilibili默认";
|
|
$files = scandir($dir);
|
|
$md5Set = [];
|
|
foreach ($files as $file) {
|
|
if ($file == "." || $file == ".." || $file == ".DS_Store") {
|
|
continue;
|
|
}
|
|
$hash = md5_file($dir . DIRECTORY_SEPARATOR . $file);
|
|
if (array_key_exists($hash, $md5Set)) {
|
|
echo "file is same $file, and {$md5Set[$hash]} \n";
|
|
} else {
|
|
$md5Set[$hash] = $file;
|
|
}
|
|
}
|
|
exit;
|
|
// $pid = pcntl_fork();
|
|
$childs = array();
|
|
|
|
$cmds = array(
|
|
array('/Users/shixuesen/Downloads/temp/dir1/1.txt', '/Users/shixuesen/Downloads/temp/dir2/1.txt'),
|
|
array('/Users/shixuesen/Downloads/temp/dir1/1.txt', '/Users/shixuesen/Downloads/temp/dir3/1.txt'),
|
|
array('/Users/shixuesen/Downloads/temp/dir1/1.txt', '/Users/shixuesen/Downloads/temp/dir4/1.txt')
|
|
);
|
|
|
|
echo 'begin';
|
|
echo date("Y-m-d H:i:s");
|
|
|
|
foreach ($cmds as $cmd) {
|
|
$pid = pcntl_fork();
|
|
if ($pid == -1) {// process creation failed
|
|
die('fork child process failure!');
|
|
} else if ($pid) {// parent process logic
|
|
$childs[] = $pid;
|
|
pcntl_wait($status, WNOHANG);
|
|
} else {// sub-process processing logic
|
|
pcntl_exec('/bin/cp', $cmd);
|
|
}
|
|
}
|
|
while (count($childs) > 0) {
|
|
foreach ($childs as $key => $pid) {
|
|
$res = pcntl_waitpid($pid, $status, WNOHANG);
|
|
|
|
//1 for error, greater than 0 representative process has been withdrawn, returns to the pid of the sub-process, and 0 representatives have not been able to take the exit sub-process when it is not blocked
|
|
if ($res == -1 || $res > 0)
|
|
unset($childs[$key]);
|
|
}
|
|
|
|
sleep(1);
|
|
}
|
|
|
|
echo "start sleep";
|
|
sleep(100);
|
|
echo date("Y-m-d H:i:s");
|
|
echo 'done';
|
|
exit;
|
|
echo time() . "\n";
|
|
$pid = pcntl_fork();
|
|
if ($pid == -1) {
|
|
die('could not fork');
|
|
} else if ($pid) {
|
|
// we are the parent
|
|
pcntl_wait($status); //Protect against Zombie children
|
|
} else {
|
|
// we are the child
|
|
pcntl_exec("/bin/cp", ["/Users/shixuesen/Downloads/temp/dir1/1.txt", "/Users/shixuesen/Downloads/temp/dir2/1.txt"]);
|
|
}
|
|
|
|
|
|
pcntl_exec("/bin/cp", ["/Users/shixuesen/Downloads/temp/dir1/1.txt", "/Users/shixuesen/Downloads/temp/dir3/1.txt"]);
|
|
pcntl_exec("/bin/cp", ["/Users/shixuesen/Downloads/temp/dir1/1.txt", "/Users/shixuesen/Downloads/temp/dir4/1.txt"]);
|
|
echo time();
|
|
exit;
|
|
|
|
$service = new GooglePhotoSyncService();
|
|
// $service->syncDBToRedis();exit;
|
|
// $service->insertMappings();exit;
|
|
$service->syncImageFiles();
|
|
exit;
|
|
// $service = new FileService();
|
|
// $service->queryFileTime("/Users/shixuesen/Documents/sync/image/instagram/mobe_carrie0223/mobe__0020/82339160_561812341080795_8865402232426240219_n.jpg");exit;
|
|
// echo $service->processDirAndFindLastFileMTime("/Users/shixuesen/Documents/sync/image/weibo/");exit;
|
|
// $service = new LiveStreamService();
|
|
// $service->moveFilesAndRenameFiles("/Users/shixuesen/Downloads/rsyncFiles/a", "/Users/shixuesen/Downloads/rsyncFiles/b");
|
|
// exit;
|
|
// $a = str_replace("/", "", "aaaaa/bbbb");
|
|
// echo $a;exit;
|
|
//
|
|
$file = "/Volumes/Crucial X6/Image/weibo/image/一只小短短OwO--7f605a17gy1gxpb0pg31vj22eo37k1kz.jpg";
|
|
$file = "/Users/shixuesen/Documents/sync/image/instagram/Likes/eeelyeee_277962893_719835709026094_2370282265319075961_n.jpg";
|
|
// $file = "/Users/shixuesen/OneDrive/Pictures/instagram/Likes_new/eeelyeee_277962893_719835709026094_2370282265319075961_n.jpg";
|
|
|
|
|
|
$file = "/Users/shixuesen/Documents/sync/image/instagram/boram__jj/277958530_1581189285586989_5049761303029075957_n.jpg";
|
|
// $file = "/Users/shixuesen/OneDrive/Pictures/instagram/boram__jj/277958530_1581189285586989_5049761303029075957_n.jpg";
|
|
$mtime = date("Y-m-d H:i:s", filemtime($file));
|
|
$atime = date("Y-m-d H:i:s", fileatime($file));
|
|
$ctime = date("Y-m-d H:i:s", filectime($file));
|
|
// $stat = stat($file);
|
|
echo "file mtime is $mtime, atime is $atime, ctime is $ctime";
|
|
// dump($stat);
|
|
|
|
}
|
|
}
|