CC-2977: Never delete files from the database
- Files are marked deleted(file_exists to false) on deletion. - Dirs are marked removed(removed flag to true) on removal of watched folder in a usual way. If dir is unmounted, without being removed from watched list first, it will be marked as not exists(exist flag to false) - Manage Media Folders will show if dirs exist or not( mounted or not) - Playlist builder will show if files exists or not
This commit is contained in:
parent
61c5355e8a
commit
04b48d47cc
16 changed files with 374 additions and 69 deletions
|
@ -42,6 +42,13 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* The value for the exists field.
|
||||
* Note: this column has a database default value of: true
|
||||
* @var boolean
|
||||
*/
|
||||
protected $exists;
|
||||
|
||||
/**
|
||||
* The value for the removed field.
|
||||
* Note: this column has a database default value of: false
|
||||
|
@ -76,6 +83,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
*/
|
||||
public function applyDefaultValues()
|
||||
{
|
||||
$this->exists = true;
|
||||
$this->removed = false;
|
||||
}
|
||||
|
||||
|
@ -119,6 +127,16 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [exists] column value.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getExists()
|
||||
{
|
||||
return $this->exists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [removed] column value.
|
||||
*
|
||||
|
@ -189,6 +207,27 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
return $this;
|
||||
} // setType()
|
||||
|
||||
/**
|
||||
* Set the value of [exists] column.
|
||||
*
|
||||
* @param boolean $v new value
|
||||
* @return CcMusicDirs The current object (for fluent API support)
|
||||
*/
|
||||
public function setExists($v)
|
||||
{
|
||||
Logging::log("setting exists to ".print_r($v, true));
|
||||
if ($v !== null) {
|
||||
$v = (boolean) $v;
|
||||
}
|
||||
|
||||
if ($this->exists !== $v || $this->isNew()) {
|
||||
$this->exists = $v;
|
||||
$this->modifiedColumns[] = CcMusicDirsPeer::EXISTS;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setExists()
|
||||
|
||||
/**
|
||||
* Set the value of [removed] column.
|
||||
*
|
||||
|
@ -219,6 +258,10 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
*/
|
||||
public function hasOnlyDefaultValues()
|
||||
{
|
||||
if ($this->exists !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->removed !== false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -248,7 +291,8 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
|
||||
$this->directory = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
|
||||
$this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
|
||||
$this->removed = ($row[$startcol + 3] !== null) ? (boolean) $row[$startcol + 3] : null;
|
||||
$this->exists = ($row[$startcol + 3] !== null) ? (boolean) $row[$startcol + 3] : null;
|
||||
$this->removed = ($row[$startcol + 4] !== null) ? (boolean) $row[$startcol + 4] : null;
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
@ -257,7 +301,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 4; // 4 = CcMusicDirsPeer::NUM_COLUMNS - CcMusicDirsPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 5; // 5 = CcMusicDirsPeer::NUM_COLUMNS - CcMusicDirsPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating CcMusicDirs object", $e);
|
||||
|
@ -584,6 +628,9 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
return $this->getType();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getExists();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getRemoved();
|
||||
break;
|
||||
default:
|
||||
|
@ -612,7 +659,8 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getDirectory(),
|
||||
$keys[2] => $this->getType(),
|
||||
$keys[3] => $this->getRemoved(),
|
||||
$keys[3] => $this->getExists(),
|
||||
$keys[4] => $this->getRemoved(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
@ -654,6 +702,9 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
$this->setType($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setExists($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setRemoved($value);
|
||||
break;
|
||||
} // switch()
|
||||
|
@ -683,7 +734,8 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setDirectory($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setRemoved($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setExists($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setRemoved($arr[$keys[4]]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -698,6 +750,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
if ($this->isColumnModified(CcMusicDirsPeer::ID)) $criteria->add(CcMusicDirsPeer::ID, $this->id);
|
||||
if ($this->isColumnModified(CcMusicDirsPeer::DIRECTORY)) $criteria->add(CcMusicDirsPeer::DIRECTORY, $this->directory);
|
||||
if ($this->isColumnModified(CcMusicDirsPeer::TYPE)) $criteria->add(CcMusicDirsPeer::TYPE, $this->type);
|
||||
if ($this->isColumnModified(CcMusicDirsPeer::EXISTS)) $criteria->add(CcMusicDirsPeer::EXISTS, $this->exists);
|
||||
if ($this->isColumnModified(CcMusicDirsPeer::REMOVED)) $criteria->add(CcMusicDirsPeer::REMOVED, $this->removed);
|
||||
|
||||
return $criteria;
|
||||
|
@ -762,6 +815,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
{
|
||||
$copyObj->setDirectory($this->directory);
|
||||
$copyObj->setType($this->type);
|
||||
$copyObj->setExists($this->exists);
|
||||
$copyObj->setRemoved($this->removed);
|
||||
|
||||
if ($deepCopy) {
|
||||
|
@ -962,6 +1016,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent
|
|||
$this->id = null;
|
||||
$this->directory = null;
|
||||
$this->type = null;
|
||||
$this->exists = null;
|
||||
$this->removed = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->alreadyInValidation = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue