aboutsummaryrefslogtreecommitdiff
path: root/bpkg/rep-fetch.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-03-02 20:22:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-03-02 20:22:08 +0200
commit668597d78359e7ee44aeda65c6bb6fcf09624932 (patch)
tree907487c32d53af3ed4c415537a41a2a67924eaa5 /bpkg/rep-fetch.cxx
parent1374560d558f4cab72f66b3d851e2a052f59998d (diff)
Improve filesystem modification detection
Diffstat (limited to 'bpkg/rep-fetch.cxx')
-rw-r--r--bpkg/rep-fetch.cxx47
1 files changed, 24 insertions, 23 deletions
diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx
index 3bede3c..9cd6164 100644
--- a/bpkg/rep-fetch.cxx
+++ b/bpkg/rep-fetch.cxx
@@ -177,20 +177,19 @@ namespace bpkg
auto_rmdir rm (temp_dir / sd);
dir_path& td (rm.path);
- // We are about to modify the repository filesystem state.
- //
- // In the future we can probably do something smarter about the flag,
- // keeping it unset unless the repository state directory is really
- // changed.
- //
- filesystem_state_changed = true;
-
if (exists (td))
rm_r (td);
// If the git repository directory already exists, then we are fetching
// an already cloned repository. Move it to the temporary directory.
//
+ // In this case also set the filesystem_state_changed flag since we are
+ // modifying the repository filesystem state.
+ //
+ // In the future we can probably do something smarter about the flag,
+ // keeping it unset unless the repository state directory is really
+ // changed.
+ //
dir_path rd;
bool fetch (false);
if (conf != nullptr)
@@ -200,29 +199,19 @@ namespace bpkg
if (exists (rd))
{
mv (rd, td);
+ filesystem_state_changed = true;
fetch = true;
}
}
dir_path nm (fetch ? git_fetch (co, rl, td) : git_clone (co, rl, td));
-
- if (!rd.empty ())
- mv (td, rd);
- else
- // If there is no configuration directory then we leave the repository
- // in the temporary directory.
- //
- rd = move (td);
-
- rm.cancel ();
-
- rd /= nm;
+ dir_path fd (td / nm); // Full directory path.
// Produce repository manifest list.
//
git_repository_manifests rms;
{
- path f (rd / path ("repositories"));
+ path f (fd / path ("repositories"));
if (exists (f))
rms = parse_manifest<git_repository_manifests> (f, ignore_unknown, rl);
@@ -234,7 +223,7 @@ namespace bpkg
//
git_package_manifests pms;
{
- path f (rd / path ("packages"));
+ path f (fd / path ("packages"));
if (exists (f))
pms = parse_manifest<git_package_manifests> (f, ignore_unknown, rl);
@@ -271,7 +260,7 @@ namespace bpkg
package_info (dr);
};
- dir_path d (rd / path_cast<dir_path> (*sm.location));
+ dir_path d (fd / path_cast<dir_path> (*sm.location));
path f (d / path ("manifest"));
if (!exists (f))
@@ -398,6 +387,18 @@ namespace bpkg
}
}
+ // Move the state directory to its proper place.
+ //
+ // If there is no configuration directory then we let auto_rmdir clean it
+ // up from the the temporary directory.
+ //
+ if (!rd.empty ())
+ {
+ mv (td, rd);
+ rm.cancel ();
+ filesystem_state_changed = true;
+ }
+
return rep_fetch_data {move (rms), move (fps), nullptr};
}