}
this->file = strdup(file);
- e = this->db->query(this->db, "SELECT id FROM file WHERE path = ?",
+ e = this->db->query(this->db, "SELECT id FROM files WHERE path = ?",
DB_TEXT, file, DB_INT);
if (e)
{
free(this->dir);
this->dir = strdup(dir);
- e = this->db->query(this->db, "SELECT id FROM file WHERE path = ?",
+ e = this->db->query(this->db, "SELECT id FROM files WHERE path = ?",
DB_TEXT, dir, DB_INT);
if (e)
{
}
this->did = did;
- e = this->db->query(this->db, "SELECT path FROM file WHERE id = ?",
+ e = this->db->query(this->db, "SELECT path FROM files WHERE id = ?",
DB_INT, did, DB_TEXT);
if (e)
{
e = this->db->query(this->db,
"SELECT f.id, f.type, f.path FROM files AS f "
"JOIN product_file AS pf ON f.id = pf.file "
- "JOIN products AS p ON p.id = pf.product "
- "WHERE p.id = ? ORDER BY f.path",
+ "WHERE pf.product = ? ORDER BY f.path",
DB_INT, this->pid, DB_INT, DB_INT, DB_TEXT);
}
else
e = this->db->query(this->db,
"SELECT p.id, p.name FROM products AS p "
"JOIN product_file AS pf ON p.id = pf.product "
- "JOIN files AS f ON f.id = pf.file "
- "WHERE f.id = ? ORDER BY p.name",
+ "WHERE pf.file = ? ORDER BY p.name",
DB_INT, this->fid, DB_INT, DB_TEXT);
}
else
"SELECT f.id, f. f.path, fh.hash, fh.directory "
"FROM file_hashes AS fh "
"JOIN files AS f ON f.id = fh.file "
- "JOIN products AS p ON p.id = fh.product "
- "WHERE fh.algo = ? AND p.id = ? "
+ "WHERE fh.algo = ? AND fh.product = ? "
"ORDER BY fh.directory, f.path",
DB_INT, this->algo, DB_INT, this->pid,
DB_INT, DB_TEXT, DB_BLOB, DB_INT);
e = this->db->query(this->db,
"SELECT p.name, fh.hash, fh.directory "
"FROM file_hashes AS fh "
- "JOIN files AS f ON f.id = fh.file "
"JOIN products AS p ON p.id = fh.product "
- "WHERE fh.algo = ? AND f.id = ? "
+ "WHERE fh.algo = ? AND fh.file = ? AND fh.directory = ?"
"ORDER BY p.name",
- DB_INT, this->algo, DB_INT, this->fid,
+ DB_INT, this->algo, DB_INT, this->fid, DB_INT, this->did,
DB_TEXT, DB_BLOB, DB_INT);
if (e)
{
}
e->destroy(e);
- get_directory(this, did, &dir);
printf("%d %N value%s found for file '%s%s%s'\n",
count, hash_algorithm_names, pts_meas_algo_to_hash(this->algo),
- (count == 1) ? "" : "s",
- dir, slash(dir, this->file) ? "/" : "", this->file);
+ (count == 1) ? "" : "s", this->dir,
+ slash(this->dir, this->file) ? "/" : "", this->file);
}
}
else