-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Listen to scanned files and to generate previews for externally added files (if possible) #484
Comments
Are the files added to the external storage directly or via Nextcloud? |
apologies for delayed response. it is added directly via rsync, not via nextcloud. if doing it this way is a problem, is there any other way to get preview generation working? |
@st3iny sorry to bump but would you have any suggestions for my situation? |
It seems that when files are added externally (e.g. rsync) changes are not caught. Same situation here, running on docker and using locally mounted external storage. |
i suspected as much. Is there another way to get these files to be picked up by preview generator? |
Add external files via the webdav interface provided by nextcloud. Should work then, let us know if it does (for reference). |
Yeah, that is correct. Only files that are added or modified using either the desktop client, webdav or the web interface are registered. Adding the files externally and running a scan will not pick up changes unfortunately. For now there is no workaround. The proper fix would be to implement a new listener to listen for scanned files (if possible). |
This is definitely a major issue for those of us manipulating files externally. It seems that this app should listen for |
I started working on this but then realized that we don't have node ID information in the namespace OCA\PreviewGenerator\Listeners;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Events\FileScannedEvent;
use OCP\Files\Folder;
use OCP\IDBConnection;
use OCP\IUserManager;
class PostWriteListener implements IEventListener {
private IDBConnection $connection;
private IUserManager $userManager;
public function __construct(IDBConnection $connection,
IUserManager $userManager) {
$this->connection = $connection;
$this->userManager = $userManager;
}
public function handle(Event $event): void {
if (!($event instanceof FileScannedEvent)) {
return;
}
$absPath = $event->getAbsolutePath();
$id = #TODO --- FIGURE OUT HOW TO GET THE ID OF THE FILE;
$owner = explode('/', $absPath)[0];
if (!$this->userManager->userExists($owner)) {
return;
}
$qb = $this->connection->getQueryBuilder();
$qb->select('id')
->from('preview_generation')
->where(
$qb->expr()->andX(
$qb->expr()->eq('uid', $qb->createNamedParameter($owner)),
$qb->expr()->eq('file_id', $qb->createNamedParameter($id))
)
)->setMaxResults(1);
$cursor = $qb->execute();
$inTable = $cursor->fetch() !== false;
$cursor->closeCursor();
// Don't insert if there is already such an entry
if ($inTable) {
return;
}
$qb = $this->connection->getQueryBuilder();
$qb->insert('preview_generation')
->setValue('uid', $qb->createNamedParameter($owner))
->setValue('file_id', $qb->createNamedParameter($id));
$qb->execute();
}
} ======== One option might be to copy what the Recognize app does: https://github.com/nextcloud/recognize/blob/main/lib/Hooks/FileListener.php |
I have a snap install of Nextcloud on an aws instance and running into issues with generating previews for a smb share. The external drive is mounted and its added to nextcloud's UI via External Storage -> Local. The problem is when new files are being added to the external storage, pre-generate does not do anything (it is on a hourly cron job). Running it manually with the -vvv flag finishes in a second without any additional output. Meanwhile running '''generate-all -vvv''' slowly goes through all the new files as per usual. How would i go about addressing this issue?
The text was updated successfully, but these errors were encountered: