From 31ff7088a2e873bd7cf43c2af722746e079df5ed Mon Sep 17 00:00:00 2001 From: "mozilla.mano%sent.com" Date: Tue, 10 Jul 2007 07:57:31 +0000 Subject: [PATCH] Bug 385828 - Insertion, removal and move operations of items should update the last-modified field of their containing folder. r=dietrich. --- .../components/places/src/nsNavBookmarks.cpp | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/toolkit/components/places/src/nsNavBookmarks.cpp b/toolkit/components/places/src/nsNavBookmarks.cpp index d57497ad75b..7d31a82c4e5 100644 --- a/toolkit/components/places/src/nsNavBookmarks.cpp +++ b/toolkit/components/places/src/nsNavBookmarks.cpp @@ -939,6 +939,9 @@ nsNavBookmarks::InsertBookmark(PRInt64 aFolder, nsIURI *aItem, PRInt32 aIndex, NS_ENSURE_SUCCESS(rv, rv); *aNewBookmarkId = rowId; + rv = SetItemLastModified(aFolder, PR_Now()); + NS_ENSURE_SUCCESS(rv, rv); + rv = transaction.Commit(); NS_ENSURE_SUCCESS(rv, rv); @@ -993,6 +996,9 @@ nsNavBookmarks::RemoveItem(PRInt64 aItemId) NS_ENSURE_SUCCESS(rv, rv); } + rv = SetItemLastModified(folderId, PR_Now()); + NS_ENSURE_SUCCESS(rv, rv); + rv = transaction.Commit(); NS_ENSURE_SUCCESS(rv, rv); @@ -1076,7 +1082,10 @@ nsNavBookmarks::CreateFolderWithID(PRInt64 aFolder, PRInt64 aParent, PRInt64 id; rv = dbConn->GetLastInsertRowID(&id); NS_ENSURE_SUCCESS(rv, rv); - + + rv = SetItemLastModified(aParent, PR_Now()); + NS_ENSURE_SUCCESS(rv, rv); + rv = transaction.Commit(); NS_ENSURE_SUCCESS(rv, rv); @@ -1168,6 +1177,9 @@ nsNavBookmarks::InsertSeparator(PRInt64 aParent, PRInt32 aIndex, NS_ENSURE_SUCCESS(rv, rv); *aNewItemId = rowId; + rv = SetItemLastModified(aParent, PR_Now()); + NS_ENSURE_SUCCESS(rv, rv); + rv = transaction.Commit(); NS_ENSURE_SUCCESS(rv, rv); @@ -1304,6 +1316,9 @@ nsNavBookmarks::RemoveFolder(PRInt64 aFolder) rv = AdjustIndices(parent, index + 1, PR_INT32_MAX, -1); NS_ENSURE_SUCCESS(rv, rv); + rv = SetItemLastModified(parent, PR_Now()); + NS_ENSURE_SUCCESS(rv, rv); + rv = transaction.Commit(); NS_ENSURE_SUCCESS(rv, rv); @@ -1530,6 +1545,12 @@ nsNavBookmarks::MoveItem(PRInt64 aItemId, PRInt64 aNewParent, PRInt32 aIndex) rv = dbConn->ExecuteSimpleSQL(buffer); NS_ENSURE_SUCCESS(rv, rv); + PRTime now = PR_Now(); + rv = SetItemLastModified(oldParent, now); + NS_ENSURE_SUCCESS(rv, rv); + rv = SetItemLastModified(aNewParent, now); + NS_ENSURE_SUCCESS(rv, rv); + rv = transaction.Commit(); NS_ENSURE_SUCCESS(rv, rv); @@ -1695,10 +1716,10 @@ nsNavBookmarks::SetItemTitle(PRInt64 aItemId, const nsAString &aTitle) rv = statement->Execute(); NS_ENSURE_SUCCESS(rv, rv); - rv = transaction.Commit(); + rv = SetItemLastModified(aItemId, PR_Now()); NS_ENSURE_SUCCESS(rv, rv); - rv = SetItemLastModified(aItemId, PR_Now()); + rv = transaction.Commit(); NS_ENSURE_SUCCESS(rv, rv); ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, @@ -2066,6 +2087,9 @@ nsNavBookmarks::ChangeBookmarkURI(PRInt64 aBookmarkId, nsIURI *aNewURI) rv = statement->Execute(); NS_ENSURE_SUCCESS(rv, rv); + rv = SetItemLastModified(aBookmarkId, PR_Now()); + NS_ENSURE_SUCCESS(rv, rv); + rv = transaction.Commit(); NS_ENSURE_SUCCESS(rv, rv); @@ -2073,9 +2097,6 @@ nsNavBookmarks::ChangeBookmarkURI(PRInt64 aBookmarkId, nsIURI *aNewURI) rv = aNewURI->GetSpec(spec); NS_ENSURE_SUCCESS(rv, rv); - rv = SetItemLastModified(aBookmarkId, PR_Now()); - NS_ENSURE_SUCCESS(rv, rv); - // Pass the new URI to OnItemChanged. ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, OnItemChanged(aBookmarkId, NS_LITERAL_CSTRING("uri"), PR_FALSE, spec)) @@ -2271,11 +2292,12 @@ nsNavBookmarks::SetKeywordForBookmark(PRInt64 aBookmarkId, const nsAString& aKey NS_ENSURE_SUCCESS(rv, rv); rv = updateKeywordStmnt->Execute(); NS_ENSURE_SUCCESS(rv, rv); - transaction.Commit(); - + rv = SetItemLastModified(aBookmarkId, PR_Now()); NS_ENSURE_SUCCESS(rv, rv); + transaction.Commit(); + // Pass the new keyword to OnItemChanged. ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver, OnItemChanged(aBookmarkId, NS_LITERAL_CSTRING("keyword"),