初步实现 westdc/dataset-file-check#1 ,查看某数据集的具体文件差异
This commit is contained in:
parent
3015ef6747
commit
a96424f86a
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
uuid=$1
|
||||||
|
if [ $# -ne 1 ]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 {DATA_UUID}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm $uuid-db.txt $uuid-fs.txt Diff.html
|
||||||
|
php -f dataset-files.php $uuid
|
||||||
|
datapath=`head -1 $uuid-db.txt`
|
||||||
|
echo $datapath >> $uuid-fs.txt
|
||||||
|
fcount=`find -L "$datapath"/* | wc -l`
|
||||||
|
curpath=`pwd`
|
||||||
|
if [ $fcount -gt 0 ]; then
|
||||||
|
cd $datapath
|
||||||
|
find . -printf "%p %s\n" | grep -v '. 4096' | sort >> $curpath/$uuid-fs.txt
|
||||||
|
else
|
||||||
|
echo $datapath;
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $curpath
|
||||||
|
if ! diff -q $uuid-db.txt $uuid-fs.txt > /dev/null; then
|
||||||
|
vimdiff -c ":TOhtml | :wq | :q | :q" $uuid-db.txt $uuid-fs.txt
|
||||||
|
cp Diff.html /var/www/ftp2.westgis.ac.cn/diff/$uuid-diff.html
|
||||||
|
fi
|
||||||
|
exit 0
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
$link = pg_connect("dbname=metadata user=gis password=gispassword host=210.77.68.241");
|
||||||
|
$host='ftp2.westgis.ac.cn';
|
||||||
|
//接收uuid
|
||||||
|
if($argc==2)
|
||||||
|
{
|
||||||
|
$uuid = $argv[1];
|
||||||
|
} else {
|
||||||
|
$uuid = @$_GET['uuid'];
|
||||||
|
}
|
||||||
|
if (""===trim($uuid)) die('Please offer an UUID!');
|
||||||
|
|
||||||
|
$sql="select path from dataset where uuid='".$uuid."'";
|
||||||
|
$result=pg_query($link,$sql);
|
||||||
|
$row = pg_fetch_row($result);
|
||||||
|
$content=$row[0]."\n";
|
||||||
|
|
||||||
|
$sql="select filename,filesize from datafile where dsid in (select id from dataset where uuid='".$uuid."' and host='".$host."') order by filename";
|
||||||
|
$result = pg_query($link, $sql);
|
||||||
|
$numrows = pg_num_rows($result);
|
||||||
|
|
||||||
|
for($ri = 0; $ri < $numrows; $ri++)
|
||||||
|
{
|
||||||
|
$row = pg_fetch_array($result, $ri);
|
||||||
|
$content.="./".rtrim($row['filename'],'/')." ";
|
||||||
|
$content.=$row['filesize']."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename=$uuid.'-db.txt';
|
||||||
|
if (!empty($content))
|
||||||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||||||
|
die("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pg_free_result($result);
|
||||||
|
pg_close($link);
|
Loading…
Reference in New Issue