fix get_file_id() (sometimes) not finding the right id for shared directories or writable Collabora shares

This commit is contained in:
Ralf Becker 2022-01-27 21:15:36 +02:00
parent ea8ef4d077
commit 855b786d97

View File

@ -1639,7 +1639,7 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface
* Get the lowest file id (fs_id) for a given path * Get the lowest file id (fs_id) for a given path
* *
* @param string $path * @param string $path
* @return integer * @return ?integer null if path not found
*/ */
static function get_minimum_file_id($path) static function get_minimum_file_id($path)
{ {
@ -1651,10 +1651,21 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface
} }
$fs_id = $stat['ino']; $fs_id = $stat['ino'];
//error_log(__METHOD__."('$path') stat[ino]=$fs_id");
return $fs_id ? self::get_minimum_fs_id($fs_id) : null;
}
/**
* Get the lowest file id (fs_id) for a given fs_id
*
* @param string $path
* @return ?integer null if fs_id is NOT found
*/
static function get_minimum_fs_id($fs_id)
{
$query = 'SELECT MIN(B.fs_id) $query = 'SELECT MIN(B.fs_id)
FROM ' . self::TABLE . ' as A FROM ' . self::TABLE . ' as A
JOIN ' . self::TABLE . ' AS B ON A.fs_name = B.fs_name AND A.fs_dir = B.fs_dir AND A.fs_active = ' . JOIN ' . self::TABLE . ' AS B ON A.fs_name = B.fs_name AND A.fs_dir = B.fs_dir
self::_pdo_boolean(true) . ' AND B.fs_active = ' . self::_pdo_boolean(false) . '
WHERE A.fs_id=? WHERE A.fs_id=?
GROUP BY A.fs_id'; GROUP BY A.fs_id';
if (self::LOG_LEVEL > 2) if (self::LOG_LEVEL > 2)
@ -1666,7 +1677,8 @@ GROUP BY A.fs_id';
$stmt->execute(array($fs_id)); $stmt->execute(array($fs_id));
$min = $stmt->fetchColumn(); $min = $stmt->fetchColumn();
return $min ? $min : $fs_id; //error_log(__METHOD__."($fs_id) returning ".($min ?: null));
return $min ?: null;
} }
/** /**