Skip to content

Commit 33e7189

Browse files
committed
fix(file_sharing): skip unresolvable roots and simplify empty-path guards per review
1 parent 42d09c6 commit 33e7189

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/file_sharing/directory_updater.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,17 @@ bool LocalDirectoryUpdater::sweepSharedDirectories(bool& some_files_not_ready)
220220
RS_DBG4("recursing into \"", stored_dir_it.name());
221221

222222
std::string canonical = RsDirUtil::removeSymLinks(stored_dir_it.name());
223+
223224
if(!canonical.empty())
225+
{
224226
existing_dirs.insert(canonical);
225-
std::set<std::string> current_branch_real_paths;
226-
if(!canonical.empty())
227-
current_branch_real_paths.insert(canonical);
228-
recursUpdateSharedDir(
229-
stored_dir_it.name(), *stored_dir_it,
230-
existing_dirs, current_branch_real_paths, 1, some_files_not_ready );
227+
228+
std::set<std::string> current_branch_real_paths = { canonical };
229+
230+
recursUpdateSharedDir(
231+
stored_dir_it.name(), *stored_dir_it,
232+
existing_dirs, current_branch_real_paths, 1, some_files_not_ready );
233+
}
231234
/* here we need to use the list that was stored, instead of the shared
232235
* dir list, because the two are not necessarily in the same order. */
233236
}
@@ -387,16 +390,18 @@ void LocalDirectoryUpdater::recursUpdateSharedDir(
387390
stored_dir_it; ++stored_dir_it )
388391
{
389392
std::string next_path = RsDirUtil::makePath(cumulated_path, stored_dir_it.name());
393+
394+
// canonical cannot be empty here: directories with unresolvable paths
395+
// were already filtered out during the subdirs collection phase above.
390396
std::string canonical = RsDirUtil::removeSymLinks(next_path);
391-
if(!canonical.empty())
392-
current_branch_real_paths.insert(canonical);
397+
398+
current_branch_real_paths.insert(canonical);
393399

394400
recursUpdateSharedDir( next_path,
395401
*stored_dir_it, existing_directories, current_branch_real_paths,
396402
current_depth+1, some_files_not_ready );
397403

398-
if(!canonical.empty())
399-
current_branch_real_paths.erase(canonical);
404+
current_branch_real_paths.erase(canonical);
400405
}
401406
}
402407

0 commit comments

Comments
 (0)