aboutsummaryrefslogtreecommitdiffstats
path: root/util/storageconv
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-03-24 09:58:21 +0000
committerMario <mario@mariovavti.com>2024-03-24 09:58:21 +0000
commita0cfe22501dc9daa7dd8cff86803cf494a1f5ec3 (patch)
treee156db21df2251b8c67e61453c8f4af9f9460d2f /util/storageconv
parentecdd9a4d6edd769a3e2c3b0604e4637d94fa1a51 (diff)
parent0dc959d9fe40bddce5e99b8162bb0e770fc28ed9 (diff)
downloadvolse-hubzilla-a0cfe22501dc9daa7dd8cff86803cf494a1f5ec3.tar.gz
volse-hubzilla-a0cfe22501dc9daa7dd8cff86803cf494a1f5ec3.tar.bz2
volse-hubzilla-a0cfe22501dc9daa7dd8cff86803cf494a1f5ec3.zip
Merge branch 'deprecate-include-config-in-core' into 'dev'
Deprecate *_config() functions in core. See merge request hubzilla/core!2114
Diffstat (limited to 'util/storageconv')
-rwxr-xr-xutil/storageconv21
1 files changed, 11 insertions, 10 deletions
diff --git a/util/storageconv b/util/storageconv
index 676425038..fe12137a3 100755
--- a/util/storageconv
+++ b/util/storageconv
@@ -18,6 +18,7 @@ require_once('include/cli_startup.php');
cli_startup();
+use Zotlabs\Lib\Config;
use Zotlabs\Lib\Hashpath;
if($argc == 1) {
@@ -26,8 +27,8 @@ if($argc == 1) {
}
if($argc == 2) {
-
- $storage = (intval(get_config('system','photo_storage_type', 1)) > 0 ? 1 : 0);
+
+ $storage = (intval(Config::Get('system','photo_storage_type', 1)) > 0 ? 1 : 0);
echo 'Current storage set to: ' . ($storage ? 'filesystem' : 'SQL database') . PHP_EOL;
switch($argv[1]) {
case 'stats':
@@ -38,14 +39,14 @@ if($argc == 2) {
$xx = intval($x[0]['qty']);
$x = q("SELECT COUNT(resource_id) AS qty FROM photo WHERE photo_usage IN (1, 2)");
echo 'Imported profiles thumbnails: ' . $x[0]['qty'] . PHP_EOL;
- $xx += intval($x[0]['qty']);
+ $xx += intval($x[0]['qty']);
echo 'Thumbnails total: ' . $xx . PHP_EOL;
$x = q("SELECT COUNT(id) AS qty FROM photo WHERE os_storage != %d AND imgscale > 0",
$storage
);
echo 'Thumbnails to convert: ' . $x[0]['qty'] . PHP_EOL;
break;
-
+
case 'fs':
if($storage == 0) {
echo 'Please set system.photo_storage_type to 1 before move thumbnails to filesystem storage' . PHP_EOL;
@@ -101,7 +102,7 @@ if($argc == 2) {
}
echo $i . PHP_EOL . 'Total thumbnails processed: ' . $i;
break;
-
+
case 'db':
if($storage == 1) {
echo 'Please set system.photo_storage_type to 0 before move thumbnails to SQL database storage' . PHP_EOL;
@@ -119,15 +120,15 @@ if($argc == 2) {
$x = q("SELECT id, uid, resource_id, content, imgscale FROM photo WHERE id > %d AND os_storage = 1 AND imgscale > 0 ORDER BY id LIMIT 10",
intval($cur_id)
);
-
+
if($x) {
foreach($x as $xx) {
-
+
$filename = dbunescbin($xx['content']);
$content = file_get_contents($filename);
if($content) {
-
+
$z = q("UPDATE photo SET content = '%s', os_storage = 0 WHERE id = %d",
dbescbin($content),
intval($xx['id'])
@@ -136,7 +137,7 @@ if($argc == 2) {
echo PHP_EOL . 'Failed to update stored file metadata ' . $filename . PHP_EOL;
continue;
}
-
+
@unlink($filename);
}
else
@@ -152,7 +153,7 @@ if($argc == 2) {
}
echo $i . PHP_EOL . 'Total files processed: ' . $i;
break;
-
+
default:
usage();
return;