Commit 7b90be19 authored by Liang Ding's avatar Liang Ding

🎨 改进社区备份

parent 73afcea7
...@@ -29,7 +29,6 @@ import org.b3log.latke.ioc.Singleton; ...@@ -29,7 +29,6 @@ import org.b3log.latke.ioc.Singleton;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.latke.util.Strings;
import org.b3log.solo.Server; import org.b3log.solo.Server;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Common; import org.b3log.solo.model.Common;
...@@ -95,8 +94,8 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> { ...@@ -95,8 +94,8 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> {
return; return;
} }
if (isLocalServer()) { if (Solos.isLocalServer()) {
LOGGER.log(Level.INFO, "Solo is running on a local server [servePath=" + Latkes.getServePath() + LOGGER.log(Level.INFO, "Solo is running on the local server [servePath=" + Latkes.getServePath() +
", serverHost=" + Latkes.getServerHost() + ", serverPort=" + Latkes.getServerPort() + "], ignored push article [title=" + title + "] to Rhy"); ", serverHost=" + Latkes.getServerHost() + ", serverPort=" + Latkes.getServerPort() + "], ignored push article [title=" + title + "] to Rhy");
return; return;
...@@ -134,11 +133,6 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> { ...@@ -134,11 +133,6 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> {
} }
} }
static boolean isLocalServer() {
return StringUtils.containsIgnoreCase(Latkes.getServePath(), "localhost") || Strings.isIPv4(Latkes.getServerHost()) ||
(StringUtils.isNotBlank(Latkes.getServerPort())) && !"80".equals(Latkes.getServerPort()) && !"443".equals(Latkes.getServerPort());
}
/** /**
* Gets the event type {@linkplain EventTypes#ADD_ARTICLE}. * Gets the event type {@linkplain EventTypes#ADD_ARTICLE}.
* *
......
...@@ -87,7 +87,7 @@ public class B3CommentSender extends AbstractEventListener<JSONObject> { ...@@ -87,7 +87,7 @@ public class B3CommentSender extends AbstractEventListener<JSONObject> {
return; return;
} }
if (B3ArticleSender.isLocalServer()) { if (Solos.isLocalServer()) {
return; return;
} }
......
...@@ -58,7 +58,7 @@ import java.util.stream.Collectors; ...@@ -58,7 +58,7 @@ import java.util.stream.Collectors;
* Export service. * Export service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.4, Dec 15, 2019 * @version 1.1.1.5, Jan 2, 2020
* @since 2.5.0 * @since 2.5.0
*/ */
@Service @Service
...@@ -273,11 +273,14 @@ public class ExportService { ...@@ -273,11 +273,14 @@ public class ExportService {
return; return;
} }
if (Latkes.getServePath().contains("localhost") || Strings.isIPv4(Latkes.getServerHost())) { if (Latkes.RuntimeMode.PRODUCTION != Latkes.getRuntimeMode()) {
return; return;
} }
if (Latkes.RuntimeMode.PRODUCTION != Latkes.getRuntimeMode()) { if (Solos.isLocalServer()) {
LOGGER.log(Level.INFO, "Solo is running on the local server [servePath=" + Latkes.getServePath() +
", serverHost=" + Latkes.getServerHost() + ", serverPort=" + Latkes.getServerPort() + "], ignored backup articles to HacPai");
return; return;
} }
......
...@@ -40,13 +40,15 @@ import org.b3log.solo.model.UserExt; ...@@ -40,13 +40,15 @@ import org.b3log.solo.model.UserExt;
import org.b3log.solo.repository.UserRepository; import org.b3log.solo.repository.UserRepository;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.*; import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
/** /**
* Solo utilities. * Solo utilities.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.9.0.4, Nov 18, 2019 * @version 1.9.0.5, Jan 2, 2020
* @since 2.8.0 * @since 2.8.0
*/ */
public final class Solos { public final class Solos {
...@@ -115,6 +117,16 @@ public final class Solos { ...@@ -115,6 +117,16 @@ public final class Solos {
return new JSONObject().put(Keys.CODE, 0).put(Keys.MSG, ""); return new JSONObject().put(Keys.CODE, 0).put(Keys.MSG, "");
} }
/**
* Checks whether Solo is running on the local server.
*
* @return {@code true} if it is, returns {@code false} otherwise
*/
public static boolean isLocalServer() {
return StringUtils.containsIgnoreCase(Latkes.getServePath(), "localhost") || Strings.isIPv4(Latkes.getServerHost()) ||
(StringUtils.isNotBlank(Latkes.getServerPort())) && !"80".equals(Latkes.getServerPort()) && !"443".equals(Latkes.getServerPort());
}
/** /**
* Constructs a failed result. * Constructs a failed result.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment