[tracker/tracker-0.6] Fix GetVolumeByPath



commit 2b12271c5b8af43915b6d05ac8488d6a4ba9147e
Author: Ivan Frade <ivan frade nokia com>
Date:   Sat May 9 16:38:35 2009 +0300

    Fix GetVolumeByPath
    
    There can be nested mount points (e.g. /home and /home/user/MyDocs), so we need to
    return the longest match for a certain path (e.g. /home/user/MyDocs/a.mp3 must return
    /home/user/MyDocs and not /home as result).
    
    Added desc sort by length to return the longest mountpoint that matches.
    
    Fixes NB#109892
---
 data/db/sqlite-stored-procs.sql |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/data/db/sqlite-stored-procs.sql b/data/db/sqlite-stored-procs.sql
index 446b375..d7ca389 100644
--- a/data/db/sqlite-stored-procs.sql
+++ b/data/db/sqlite-stored-procs.sql
@@ -129,7 +129,7 @@ GetHitDetails                  SELECT ROWID, HitCount, HitArraySize FROM HitInde
  */
 
 GetVolumeID                    SELECT VolumeID FROM Volumes WHERE UDI = ?;
-GetVolumeByPath                SELECT VolumeID FROM Volumes WHERE Enabled = 1 AND (? = MountPath OR ? LIKE (MountPath || '/%'));
+GetVolumeByPath                SELECT VolumeID FROM Volumes WHERE Enabled = 1 AND (? = MountPath OR ? LIKE (MountPath || '/%')) ORDER BY length(MountPath) DESC LIMIT 1;
 GetVolumesToClean              SELECT MountPath, VolumeID FROM Volumes WHERE DisabledDate < date('now', '-3 day');
 InsertVolume                   INSERT INTO Volumes (MountPath, UDI, Enabled, DisabledDate) VALUES (?, ?, 1, date('now'));
 EnableVolume                   UPDATE Volumes SET MountPath = ?, Enabled = 1 WHERE UDI = ?;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]