Skip to content

Commit

Permalink
🐛 导入 Markdown 文件存档时间问题 Fix #112
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Apr 23, 2020
1 parent c113deb commit 4a4c015
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/org/b3log/solo/service/ImportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* Import service.
*
* @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
*/
@Service
Expand Down Expand Up @@ -92,7 +92,7 @@ public void importMarkdowns() {
int succCnt = 0, failCnt = 0;
final Set<String> failSet = new TreeSet<>();
final Collection<File> mds = FileUtils.listFiles(markdownsPath, new String[]{"md"}, true);
if (null == mds || mds.isEmpty()) {
if (mds.isEmpty()) {
return;
}

Expand Down Expand Up @@ -187,6 +187,10 @@ private JSONObject parseArticle(final String fileName, String fileContent) {
final Date date = parseDate(elems);
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");
if (StringUtils.isNotBlank(permalink)) {
ret.put(Article.ARTICLE_PERMALINK, permalink);
Expand Down

0 comments on commit 4a4c015

Please # to comment.