/** * Returns a path where you can write instance-specific temporary data * * @param \DreamFactory\Enterprise\Database\Models\Instance $instance * @param string|null $append Optional appendage to path * * @return string * @throws DiskException */ public function getWorkPath(Instance $instance, $append = null) { $this->buildStorageMap($instance->user->storage_id_text); // Try private temp path or default to system temp if (false === ($_workPath = Disk::path([$instance->getPrivatePath(), 'tmp', $append], true))) { $_workPath = Disk::path([sys_get_temp_dir(), 'dfe', $instance->instance_id_text, $append], true); if (!$_workPath) { throw new DiskException('Unable to locate a suitable temporary directory.'); } } return $_workPath; }
/** * Build the 'paths' section of the metadata * * @param \DreamFactory\Enterprise\Database\Models\Instance $instance * * @return array */ protected static function buildPathMetadata(Instance $instance) { return ['storage-root' => InstanceStorage::getStorageRootPath(), 'storage-path' => $instance->getStoragePath(), 'private-path' => $instance->getPrivatePath(), 'owner-private-path' => $instance->getOwnerPrivatePath(), 'snapshot-path' => $instance->getSnapshotPath(), 'trash-path' => $instance->getTrashPath()]; }