Overview
Comment:Actually a more efficient way to dismiss files that don't exist
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable | 1.1.29
Files: files | file ages | folders
SHA3-256: 65ef485778571c814e5ec236f1e9fc0e0c6303dd458b877748e4bfdfd5b3fa91
User & Date: bohwaz on 2022-09-02 18:36:09
Other Links: manifest | tags
Context
2022-09-02
18:58
Missing return statement check-in: 941cbc6502 user: bohwaz tags: trunk, stable, 1.1.29
18:36
Actually a more efficient way to dismiss files that don't exist check-in: 65ef485778 user: bohwaz tags: trunk, stable, 1.1.29
18:27
Remove old search entries in web search check-in: dc50aa947b user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Files/Files.php from [0d745faabd] to [37e741f170].

43
44
45
46
47
48
49


50













51
52
53
54
55
56
57
			snippet(files_search, \'<b>\', \'</b>\', \'…\', 2, -30) AS snippet,
			rank(matchinfo(files_search), 0, 1.0, 1.0) AS points
			FROM files_search
			WHERE files_search MATCH ? %s
			ORDER BY points DESC
			LIMIT 0,50;', $where);



		return DB::getInstance()->get($query, ...$params);













	}

	static public function list(string $parent = ''): array
	{
		if ($parent !== '') {
			File::validatePath($parent);
		}







>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
			snippet(files_search, \'<b>\', \'</b>\', \'…\', 2, -30) AS snippet,
			rank(matchinfo(files_search), 0, 1.0, 1.0) AS points
			FROM files_search
			WHERE files_search MATCH ? %s
			ORDER BY points DESC
			LIMIT 0,50;', $where);

		$out = [];

		$db = DB::getInstance();
		$db->begin();

		foreach ($db->iterate($query, ...$params) as $row) {
			// Remove deleted/moved files
			if (FILE_STORAGE_BACKEND != 'SQLite' && !Files::callStorage('exists', $row->path)) {
				$db->delete('files_search', 'path = ?', $row->path);
				continue;
			}
		}

		$db->commit();

		return $out;
	}

	static public function list(string $parent = ''): array
	{
		if ($parent !== '') {
			File::validatePath($parent);
		}

Modified src/include/lib/Garradin/Web/Web.php from [a2b8cdb247] to [73d52461ad].

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
			}
			catch (ValidationException $e) {
				// Ignore validation errors, just don't add pages to index
				$errors[] = sprintf('Erreur à l\'import, page "%s": %s', str_replace(File::CONTEXT_WEB . '/', '', $f->parent), $e->getMessage());
			}
		}

		Files::syncVirtualTable(File::CONTEXT_WEB, true);

		$db->begin();
		$db->exec(sprintf('DELETE FROM files_search WHERE path NOT IN (SELECT path FROM %s);', Files::getVirtualTableName()));
		$db->commit();

		return $errors;

		/*
		// There's no need for that sync as it is triggered when loading a Page entity!
		$intersection = array_intersect_key($in_db, $exists);
		foreach ($intersection as $page) {
			$file = Files::get($page->file_path);







<
<
<
<
<
<







85
86
87
88
89
90
91






92
93
94
95
96
97
98
			}
			catch (ValidationException $e) {
				// Ignore validation errors, just don't add pages to index
				$errors[] = sprintf('Erreur à l\'import, page "%s": %s', str_replace(File::CONTEXT_WEB . '/', '', $f->parent), $e->getMessage());
			}
		}







		return $errors;

		/*
		// There's no need for that sync as it is triggered when loading a Page entity!
		$intersection = array_intersect_key($in_db, $exists);
		foreach ($intersection as $page) {
			$file = Files::get($page->file_path);