Fixing recently introduced bugs
diff --git a/gui/fs-watcher.cc b/gui/fs-watcher.cc
index 7eff410..18b6f77 100644
--- a/gui/fs-watcher.cc
+++ b/gui/fs-watcher.cc
@@ -60,7 +60,7 @@
bind (&FsWatcher::ScanDirectory_NotifyRemovals_Execute, this, m_dirPath),
"r-" + m_dirPath.toStdString ()); // only one task will be scheduled per directory
- Scheduler::scheduleOneTimeTask (m_scheduler, 0.5,
+ Scheduler::scheduleOneTimeTask (m_scheduler, 1,
bind (&FsWatcher::ScanDirectory_NotifyUpdates_Execute, this, m_dirPath),
m_dirPath.toStdString ()); // only one task will be scheduled per directory
}
@@ -76,9 +76,6 @@
_LOG_DEBUG ("Triggered DirPath: " << dirPath.toStdString ());
filesystem::path absPathTriggeredDir (dirPath.toStdString ());
- dirPath.remove (0, m_dirPath.size ());
-
- filesystem::path triggeredDir (dirPath.toStdString ());
if (!filesystem::exists (filesystem::path (absPathTriggeredDir)))
{
Scheduler::scheduleOneTimeTask (m_scheduler, 0.5,
@@ -129,7 +126,7 @@
void
FsWatcher::ScanDirectory_NotifyUpdates_Execute (QString dirPath)
{
- // _LOG_TRACE (" >> ScanDirectory_NotifyUpdates_Execute");
+ _LOG_TRACE (" >> ScanDirectory_NotifyUpdates_Execute");
// exclude working only on last component, not the full path; iterating through all directories, even excluded from monitoring
QRegExp exclude ("^(\\.|\\.\\.|\\.chronoshare|.*~|.*\\.swp)$");
@@ -147,6 +144,7 @@
QFileInfo fileInfo = dirIterator.fileInfo ();
QString name = fileInfo.fileName ();
+ _LOG_DEBUG ("+++ Scanning: " << name.toStdString ());
if (!exclude.exactMatch (name))
{
diff --git a/src/action-log.cc b/src/action-log.cc
index 2bab7ca..a6b26e4 100644
--- a/src/action-log.cc
+++ b/src/action-log.cc
@@ -303,6 +303,8 @@
ActionItemPtr
ActionLog::AddLocalActionDelete (const std::string &filename)
{
+ _LOG_DEBUG ("Adding local action DELETE");
+
sqlite3_exec (m_db, "BEGIN TRANSACTION;", 0,0,0);
CcnxCharbufPtr device_name = m_syncLog->GetLocalName ().toCcnxCharbuf ();
@@ -315,6 +317,19 @@
tie (version, parent_device_name, parent_seq_no) = GetLatestActionForFile (filename);
if (!parent_device_name) // no records exist or file was already deleted
{
+ _LOG_DEBUG ("Nothing to delete... [" << filename << "]");
+
+ // just in case, remove data from FileState
+ sqlite3_stmt *stmt;
+ sqlite3_prepare_v2 (m_db, "DELETE FROM FileState WHERE filename = ? ", -1, &stmt, 0);
+ sqlite3_bind_text (stmt, 1, filename.c_str (), filename.size (), SQLITE_TRANSIENT); // file
+
+ sqlite3_step (stmt);
+
+ _LOG_DEBUG_COND (sqlite3_errcode (m_db) != SQLITE_DONE, sqlite3_errmsg (m_db));
+
+ sqlite3_finalize (stmt);
+
sqlite3_exec (m_db, "END TRANSACTION;", 0,0,0);
return ActionItemPtr ();
}
@@ -610,7 +625,7 @@
"file_mtime=datetime(?, 'unixepoch'),"
"file_ctime=datetime(?, 'unixepoch'),"
"file_chmod=?, "
- "file_seg_num=?, "
+ "file_seg_num=? "
"WHERE type=0 AND filename=?", -1, &stmt, 0);
sqlite3_bind_blob (stmt, 1, device_name.buf (), device_name.length (), SQLITE_TRANSIENT);
@@ -710,7 +725,7 @@
sqlite3_prepare_v2 (m_db,
"SELECT filename,device_name,seq_no,file_hash,strftime('%s', file_mtime),file_chmod,file_seg_num "
" FROM FileState "
- " WHERE type = 0 AND file_hash = ?;", -1, &stmt, 0);
+ " WHERE type = 0 AND file_hash = ?", -1, &stmt, 0);
sqlite3_bind_blob(stmt, 1, hash.GetHash (), hash.GetHashBytes (), SQLITE_STATIC);
FileItemsPtr retval = make_shared<FileItems> ();