with the latest changes in master $this-userID is always the correct ID, so we no longer need the extra parameter
This commit is contained in:
parent
7240d349da
commit
060e0ad0cd
|
@ -18,7 +18,7 @@ $migrationCompleted = true;
|
||||||
if ($user !== '' && $password !== '') {
|
if ($user !== '' && $password !== '') {
|
||||||
if (\OCP\User::checkPassword($user, $password)) {
|
if (\OCP\User::checkPassword($user, $password)) {
|
||||||
$util = new Util(new \OC_FilesystemView('/'), $user);
|
$util = new Util(new \OC_FilesystemView('/'), $user);
|
||||||
if ($util->getMigrationStatus($user) !== Util::MIGRATION_COMPLETED) {
|
if ($util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) {
|
||||||
$migrationCompleted = false;
|
$migrationCompleted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1253,22 +1253,15 @@ class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief check if files are already migrated to the encryption system
|
* @brief check if files are already migrated to the encryption system
|
||||||
* @param string $uid user Id
|
|
||||||
* @return migration status, false = in case of no record
|
* @return migration status, false = in case of no record
|
||||||
* @note If records are not being returned, check for a hidden space
|
* @note If records are not being returned, check for a hidden space
|
||||||
* at the start of the uid in db
|
* at the start of the uid in db
|
||||||
*/
|
*/
|
||||||
public function getMigrationStatus($uid = null) {
|
public function getMigrationStatus() {
|
||||||
|
|
||||||
if($uid && \OCP\User::userExists($uid)) {
|
|
||||||
$userId = $uid;
|
|
||||||
} else {
|
|
||||||
$userId = $this->userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?';
|
$sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?';
|
||||||
|
|
||||||
$args = array($userId);
|
$args = array($this->userId);
|
||||||
$query = \OCP\DB::prepare($sql);
|
$query = \OCP\DB::prepare($sql);
|
||||||
|
|
||||||
$result = $query->execute($args);
|
$result = $query->execute($args);
|
||||||
|
@ -1288,21 +1281,24 @@ class Util {
|
||||||
|
|
||||||
// If no record is found
|
// If no record is found
|
||||||
if (empty($migrationStatus)) {
|
if (empty($migrationStatus)) {
|
||||||
\OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $userId . ", no record found", \OCP\Util::ERROR);
|
\OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $this->userId . ", no record found", \OCP\Util::ERROR);
|
||||||
// insert missing entry in DB with status open
|
// insert missing entry in DB with status open if the user exists
|
||||||
$sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)';
|
if (\OCP\User::userExists($this->userId)) {
|
||||||
$args = array(
|
$sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)';
|
||||||
$userId,
|
$args = array(
|
||||||
'server-side',
|
$this->userId,
|
||||||
0,
|
'server-side',
|
||||||
self::MIGRATION_OPEN
|
0,
|
||||||
);
|
self::MIGRATION_OPEN
|
||||||
$query = \OCP\DB::prepare($sql);
|
);
|
||||||
$query->execute($args);
|
$query = \OCP\DB::prepare($sql);
|
||||||
|
$query->execute($args);
|
||||||
|
|
||||||
return self::MIGRATION_OPEN;
|
return self::MIGRATION_OPEN;
|
||||||
// If a record is found
|
} else {
|
||||||
} else {
|
return false;
|
||||||
|
}
|
||||||
|
} else { // If a record is found
|
||||||
return (int)$migrationStatus[0];
|
return (int)$migrationStatus[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue