Commit 4a4c0159 authored by Liang Ding's avatar Liang Ding

🐛 导入 Markdown 文件存档时间问题 Fix #112

parent c113deb8
...@@ -35,7 +35,7 @@ import java.util.*; ...@@ -35,7 +35,7 @@ import java.util.*;
* Import service. * Import service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.6, Nov 22, 2019 * @version 1.0.1.6, Apr 23, 2020
* @since 2.2.0 * @since 2.2.0
*/ */
@Service @Service
...@@ -92,7 +92,7 @@ public class ImportService { ...@@ -92,7 +92,7 @@ public class ImportService {
int succCnt = 0, failCnt = 0; int succCnt = 0, failCnt = 0;
final Set<String> failSet = new TreeSet<>(); final Set<String> failSet = new TreeSet<>();
final Collection<File> mds = FileUtils.listFiles(markdownsPath, new String[]{"md"}, true); final Collection<File> mds = FileUtils.listFiles(markdownsPath, new String[]{"md"}, true);
if (null == mds || mds.isEmpty()) { if (mds.isEmpty()) {
return; return;
} }
...@@ -187,6 +187,10 @@ public class ImportService { ...@@ -187,6 +187,10 @@ public class ImportService {
final Date date = parseDate(elems); final Date date = parseDate(elems);
ret.put(Article.ARTICLE_CREATED, date.getTime()); ret.put(Article.ARTICLE_CREATED, date.getTime());
// 文章 id 必须使用存档时间戳,否则生成的存档时间会是当前时间
// 导入 Markdown 文件存档时间问题 https://github.com/88250/solo/issues/112
ret.put(Keys.OBJECT_ID, String.valueOf(date.getTime()));
final String permalink = (String) elems.get("permalink"); final String permalink = (String) elems.get("permalink");
if (StringUtils.isNotBlank(permalink)) { if (StringUtils.isNotBlank(permalink)) {
ret.put(Article.ARTICLE_PERMALINK, permalink); ret.put(Article.ARTICLE_PERMALINK, permalink);
......
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