mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
installer: add cache path on userdata (#22045)
* installer: add cache path on userdata * keep legacy as is * only copy * print cache path * comment old-commit-hash: 6c25b44369228915c825bbd1b178dc32f8505395
This commit is contained in:
@@ -19,12 +19,13 @@
|
||||
|
||||
#ifdef QCOM
|
||||
#define CONTINUE_PATH "/data/data/com.termux/files/continue.sh"
|
||||
#define CACHE_PATH "/system/comma/openpilot"
|
||||
#else
|
||||
#define CONTINUE_PATH "/data/continue.sh"
|
||||
#define CACHE_PATH "/usr/comma/openpilot"
|
||||
#endif
|
||||
|
||||
// TODO: remove the other paths after a bit
|
||||
const QList<QString> CACHE_PATHS = {"/data/openpilot.cache", "/system/comma/openpilot", "/usr/comma/openpilot"};
|
||||
|
||||
#define INSTALL_PATH "/data/openpilot"
|
||||
#define TMP_INSTALL_PATH "/data/tmppilot"
|
||||
|
||||
@@ -106,9 +107,18 @@ void Installer::doInstall() {
|
||||
// cleanup
|
||||
run("rm -rf " TMP_INSTALL_PATH " " INSTALL_PATH);
|
||||
|
||||
// find the cache path
|
||||
QString cache;
|
||||
for (const QString &path : CACHE_PATHS) {
|
||||
if (QDir(path).exists()) {
|
||||
cache = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// do the install
|
||||
if (QDir(CACHE_PATH).exists()) {
|
||||
cachedFetch();
|
||||
if (!cache.isEmpty()) {
|
||||
cachedFetch(cache);
|
||||
} else {
|
||||
freshClone();
|
||||
}
|
||||
@@ -120,10 +130,10 @@ void Installer::freshClone() {
|
||||
"--depth=1", "--recurse-submodules", TMP_INSTALL_PATH});
|
||||
}
|
||||
|
||||
void Installer::cachedFetch() {
|
||||
qDebug() << "Fetching with cache";
|
||||
void Installer::cachedFetch(const QString &cache) {
|
||||
qDebug() << "Fetching with cache: " << cache;
|
||||
|
||||
run("cp -rp " CACHE_PATH " " TMP_INSTALL_PATH);
|
||||
run(QString("cp -rp %1 %2").arg(cache, TMP_INSTALL_PATH).toStdString().c_str());
|
||||
int err = chdir(TMP_INSTALL_PATH);
|
||||
assert(err == 0);
|
||||
run("git remote set-branches --add origin " BRANCH);
|
||||
|
||||
@@ -24,5 +24,5 @@ private:
|
||||
|
||||
void doInstall();
|
||||
void freshClone();
|
||||
void cachedFetch();
|
||||
void cachedFetch(const QString &cache);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user