init: Add a flag to force-delete the cache
This allows batch mode upgrades with cache deletion. Change-Id: I92be9d1685f1165b039812e47c9332a8bb0ea831
This commit is contained in:
parent
61b8c842bd
commit
7a87ec3384
|
@ -10,6 +10,7 @@ installation.
|
|||
_java_ -jar gerrit.war _init_
|
||||
-d <SITE_PATH>
|
||||
[--batch]
|
||||
[--delete-caches]
|
||||
[--no-auto-start]
|
||||
[--skip-plugins]
|
||||
[--list-plugins]
|
||||
|
@ -42,6 +43,10 @@ are detected, they are *not* automatically dropped; a list of SQL
|
|||
statements to drop these objects is provided. To drop the unused
|
||||
objects these SQL statements must be executed manually.
|
||||
|
||||
--delete-caches::
|
||||
Force deletion of all persistent cache files. Note that
|
||||
re-creation of these caches may be expensive.
|
||||
|
||||
--no-auto-start::
|
||||
Don't automatically start the daemon after initializing a
|
||||
newly created site path. This permits the administrator
|
||||
|
|
|
@ -49,6 +49,10 @@ public class Init extends BaseInit {
|
|||
usage = "Batch mode; skip interactive prompting")
|
||||
private boolean batchMode;
|
||||
|
||||
@Option(name = "--delete-caches",
|
||||
usage = "Delete all persistent caches without asking")
|
||||
private boolean deleteCaches;
|
||||
|
||||
@Option(name = "--no-auto-start", usage = "Don't automatically start daemon after init")
|
||||
private boolean noAutoStart;
|
||||
|
||||
|
@ -159,6 +163,12 @@ public class Init extends BaseInit {
|
|||
return !noAutoStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean getDeleteCaches() {
|
||||
return deleteCaches;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean skipPlugins() {
|
||||
return skipPlugins;
|
||||
|
|
|
@ -119,6 +119,8 @@ public class BaseInit extends SiteProgram {
|
|||
init.flags.autoStart = getAutoStart() && init.site.isNew;
|
||||
init.flags.dev = isDev() && init.site.isNew;
|
||||
init.flags.skipPlugins = skipPlugins();
|
||||
init.flags.deleteCaches = getDeleteCaches();
|
||||
|
||||
|
||||
final SiteRun run;
|
||||
try {
|
||||
|
@ -471,4 +473,8 @@ public class BaseInit extends SiteProgram {
|
|||
protected boolean isDev() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean getDeleteCaches() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package com.google.gerrit.pgm.init;
|
|||
|
||||
import com.google.gerrit.common.FileUtil;
|
||||
import com.google.gerrit.pgm.init.api.ConsoleUI;
|
||||
import com.google.gerrit.pgm.init.api.InitFlags;
|
||||
import com.google.gerrit.pgm.init.api.InitStep;
|
||||
import com.google.gerrit.pgm.init.api.Section;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
|
@ -33,13 +34,15 @@ import java.util.List;
|
|||
@Singleton
|
||||
class InitCache implements InitStep {
|
||||
private final ConsoleUI ui;
|
||||
private final InitFlags flags;
|
||||
private final SitePaths site;
|
||||
private final Section cache;
|
||||
|
||||
@Inject
|
||||
InitCache(final ConsoleUI ui, final SitePaths site,
|
||||
final Section.Factory sections) {
|
||||
InitCache(final ConsoleUI ui, final InitFlags flags,
|
||||
final SitePaths site, final Section.Factory sections) {
|
||||
this.ui = ui;
|
||||
this.flags = flags;
|
||||
this.site = site;
|
||||
this.cache = sections.get("cache", null);
|
||||
}
|
||||
|
@ -75,7 +78,8 @@ class InitCache implements InitStep {
|
|||
}
|
||||
if (!cacheFiles.isEmpty()) {
|
||||
for (Path entry : cacheFiles) {
|
||||
if (ui.yesno(false, "Delete cache file %s", entry)) {
|
||||
if (flags.deleteCaches ||
|
||||
ui.yesno(false, "Delete cache file %s", entry)) {
|
||||
try {
|
||||
Files.deleteIfExists(entry);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -39,6 +39,9 @@ public class InitFlags {
|
|||
/** Skip plugins */
|
||||
public boolean skipPlugins;
|
||||
|
||||
/** Delete all cache files */
|
||||
public boolean deleteCaches;
|
||||
|
||||
/** Dev mode */
|
||||
public boolean dev;
|
||||
|
||||
|
|
Loading…
Reference in New Issue