[win] Refresh icon overlay after lock status changed locally.

This commit is contained in:
Jiaqiang Xu 2015-07-08 13:31:37 +08:00
parent 4b7ba81be7
commit 4c0fe32cf0
3 changed files with 39 additions and 0 deletions

View File

@ -504,6 +504,22 @@ seaf_filelock_manager_remove (SeafFilelockManager *mgr,
return 0;
}
#ifdef WIN32
static void
refresh_locked_path_status (const char *repo_id, const char *path)
{
SeafRepo *repo = seaf_repo_manager_get_repo (seaf->repo_mgr, repo_id);
if (!repo)
return;
char *fullpath = g_build_path ("/", repo->worktree, path);
seaf_sync_manager_refresh_path (seaf->sync_mgr, path);
g_free (fullpath);
}
#endif
static int
mark_file_locked_in_db (SeafFilelockManager *mgr,
const char *repo_id,
@ -561,6 +577,10 @@ seaf_filelock_manager_mark_file_locked (SeafFilelockManager *mgr,
pthread_mutex_unlock (&mgr->priv->hash_lock);
#ifdef WIN32
refresh_locked_path_status (repo_id, path);
#endif
return mark_file_locked_in_db (mgr, repo_id, path);
}
@ -612,5 +632,9 @@ seaf_filelock_manager_mark_file_unlocked (SeafFilelockManager *mgr,
pthread_mutex_unlock (&mgr->priv->hash_lock);
#ifdef WIN32
refresh_locked_path_status (repo_id, path);
#endif
return remove_locked_file_from_db (mgr, repo_id, path);
}

View File

@ -3469,4 +3469,14 @@ seaf_sync_manager_add_refresh_path (SeafSyncManager *mgr, const char *path)
g_async_queue_push (mgr->priv->refresh_paths, g_strdup(path));
}
void
seaf_sync_manager_refresh_path (SeafSyncManager *mgr, const char *path)
{
wchar_t *wpath;
wpath = win_path (path);
SHChangeNotify (SHCNE_ATTRIBUTES, SHCNF_PATHW, wpath, NULL);
g_free (wpath);
}
#endif

View File

@ -194,8 +194,13 @@ void
seaf_sync_manager_remove_active_path_info (SeafSyncManager *mgr, const char *repo_id);
#ifdef WIN32
/* Add to refresh queue */
void
seaf_sync_manager_add_refresh_path (SeafSyncManager *mgr, const char *path);
/* Refresh immediately. */
void
seaf_sync_manager_refresh_path (SeafSyncManager *mgr, const char *path);
#endif
#endif