util/dcp will now accept a directory as a destination. The directory must exist. Recursion is not yet supported.
This commit is contained in:
parent
31e62bd19e
commit
49cc952825
26
util/dcp
26
util/dcp
@ -13,18 +13,16 @@ require_once('include/attach.php');
|
|||||||
|
|
||||||
cli_startup();
|
cli_startup();
|
||||||
|
|
||||||
$srcfile = $argv[1];
|
|
||||||
$dstfile = $argv[2];
|
|
||||||
|
|
||||||
if($argc != 3) {
|
if($argc <= 3) {
|
||||||
echo "Usage: " . $argv[0] . ' source destination' . "\n";
|
echo "Usage: " . $argv[0] . ' source destination' . "\n";
|
||||||
echo 'Always run from the toplevel web directory.' . "\n";
|
echo 'Always run from the toplevel web directory.' . "\n";
|
||||||
echo 'destination should begin with store/$nickname/desired/path/filename or $nickname/desired/path/filename' . "\n";
|
echo 'destination should begin with store/$nickname/desired/path or $nickname/desired/path' . "\n";
|
||||||
echo 'destination must end with the destination filename (not a directory name).' . "\n";
|
|
||||||
echo 'Example: util/dcp /etc/motd store/joe/etc/motd' . "\n";
|
echo 'Example: util/dcp /etc/motd store/joe/etc/motd' . "\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dstfile = $argv[$argc - 1];
|
||||||
|
|
||||||
|
|
||||||
if(strpos($dstfile,'store/') === 0)
|
if(strpos($dstfile,'store/') === 0)
|
||||||
@ -38,7 +36,18 @@ if($argc != 3) {
|
|||||||
if(! $channel)
|
if(! $channel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
$isadir = false;
|
||||||
|
|
||||||
|
$r = q("select * from attach where display_path = '%s' and uid = %d limit 1",
|
||||||
|
dbesc($dstfile),
|
||||||
|
intval($channel['channel_id'])
|
||||||
|
);
|
||||||
|
|
||||||
|
if($r && $r[0]['is_dir']) {
|
||||||
|
$isadir = true;
|
||||||
|
$folder = $r[0]['hash'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
$arr = [
|
$arr = [
|
||||||
'pathname' => dirname($dstfile),
|
'pathname' => dirname($dstfile),
|
||||||
'allow_cid' => $channel['channel_allow_cid'],
|
'allow_cid' => $channel['channel_allow_cid'],
|
||||||
@ -53,6 +62,11 @@ if($argc != 3) {
|
|||||||
if($x['success'])
|
if($x['success'])
|
||||||
$folder = $x['data']['hash'];
|
$folder = $x['data']['hash'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for($x = 1; $x < ($argc - 1); $x ++) {
|
||||||
|
$srcfile = $argv[$x];
|
||||||
|
|
||||||
$hash = random_string();
|
$hash = random_string();
|
||||||
|
|
||||||
@ -75,4 +89,4 @@ if($argc != 3) {
|
|||||||
$sync = attach_export_data($channel,$hash);
|
$sync = attach_export_data($channel,$hash);
|
||||||
if($sync)
|
if($sync)
|
||||||
build_sync_packet($channel['channel_id'],array('file' => array($sync)));
|
build_sync_packet($channel['channel_id'],array('file' => array($sync)));
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user