Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

连续执行generate,public下会产生不同的结果 #65

Closed
hhlux opened this issue Jan 17, 2013 · 15 comments
Closed

连续执行generate,public下会产生不同的结果 #65

hhlux opened this issue Jan 17, 2013 · 15 comments
Labels
bug Something isn't working

Comments

@hhlux
Copy link

hhlux commented Jan 17, 2013

执行hexo generate一次,public下会产生所有的文章,但没有archives文件夹
public
2013
01
16
new_post
new_post2

当再执行一下hexo generate,public下会产生archives文件夹,但archives下除了index.html,却没有其它文章:
public
archives
2013
01
index.html

再执行一次generate,就会变回第一种情况。

另外部署到github后,点击archives经常出现404错误,但本地preview完全正常,不知道是不是因为这个generate的问题?

@hhlux
Copy link
Author

hhlux commented Jan 18, 2013

今天升级到了0.5.4,还是有同样的问题。我重新描述一下吧。

执行hexo generate一次,public下会生成正确的内容,包括2013文件夹和archives文件夹。接下来什么都不做,又执行一次hexo generate,public下的2013和archives文件夹就会被删掉。如果再执行一次generate,2013和archives文件夹又会被建立。如此反复。

另外在0.5.4下执行hexo generate的结果如下:

C:\Dev\hexo-blog>hexo generate
Loading.
Generating.
Generating. 0.00% (0/20)
Generating. 5.00% (1/20)
Generating. 10.00% (2/20)
Generating. 15.00% (3/20)
Generating. 20.00% (4/20)
Generating. 25.00% (5/20)
Generating. 30.00% (6/20)
Generating. 35.00% (7/20)
Generating. 40.00% (8/20)
Generating. 45.00% (9/20)
Generating. 50.00% (10/20)
Generating. 55.00% (11/20)
Generating. 60.00% (12/20)
Generating. 65.00% (13/20)
Generating. 70.00% (14/20)
Generating. 75.00% (15/20)
Generating. 80.00% (16/20)
Generating. 85.00% (17/20)
Generating. 90.00% (18/20)

Generated completely.
Site generated in 0.370s.

我不太确定执行结果中的这个只到了90%,而没有到100%,是不是有问题? 谢谢。

@tommy351
Copy link
Member

看起來的確頗奇怪的,試著執行hexo routes並把結果貼出來吧

@hhlux
Copy link
Author

hhlux commented Jan 18, 2013

晚上我又试了一下,上述的问题依然存在。但hexo routes的结果不受上述问题的影响,每次执行的结果都如下:

C:\Dev\hexo-blog>hexo routes
Loading.

Routes:

  • 2013/01/18/hello-world/index.html
  • archives/2013/01/index.html
  • archives/2013/index.html
  • archives/index.html
  • css/font\fontawesome-webfont.eot
  • css/font\fontawesome-webfont.svg
  • css/font\fontawesome-webfont.ttf
  • css/font\fontawesome-webfont.woff
  • css/style.css
  • fancybox/blank.gif
  • fancybox/fancybox_loading.gif
  • fancybox/fancybox_overlay.png
  • fancybox/fancybox_sprite.png
  • fancybox/jquery.fancybox.css
  • fancybox/jquery.fancybox.pack.js
  • index.html
  • js/gallery.js
  • js/jquery.imagesloaded.min.js
  • js/moment.min.js
  • js/twitter.js

Total 20 routes.

会不会跟环境有关?我用的是公司电脑,英文操作系统,普通帐户,不是administrator。

@hhlux
Copy link
Author

hhlux commented Jan 18, 2013

操作系统是英文win7。试了0.5.5,问题依旧

@hhlux
Copy link
Author

hhlux commented Jan 19, 2013

今天在中文WIN7,administrator帐户的环境下试了,一样的问题。我新装node.js和GIT,然后npm install -g hexo,然后hexo init hexo-blog,进入hexo-blog执行hexo-generate,会产生2013和archives,再执行一次,2013和archives就被删掉了。
是不是有些特殊的设置需要先配置?

@hhlux
Copy link
Author

hhlux commented Jan 19, 2013

我调试了一下C:\Users\heeefciy\AppData\Roaming\npm-cache\hexo\0.5.6\package\lib\cli\generate.js文件,让输出结果如下:

C:\Dev\hexo-blog>hexo generate
Loading.
Generating.
Generating.---- 0.00% (0/20)readable:C:\Dev\hexo-blog\themes\light\source\fancybox\blank.gif
Generating.---- 5.00% (1/20)readable:C:\Dev\hexo-blog\themes\light\source\fancybox\fancybox_loading.gif
Generating.---- 10.00% (2/20)readable:C:\Dev\hexo-blog\themes\light\source\fancybox\fancybox_overlay.png
Generating.---- 15.00% (3/20)readable:C:\Dev\hexo-blog\themes\light\source\fancybox\fancybox_sprite.png
Generating.---- 20.00% (4/20)readable:C:\Dev\hexo-blog\themes\light\source\fancybox\jquery.fancybox.css
Generating.---- 25.00% (5/20)readable:C:\Dev\hexo-blog\themes\light\source\fancybox\jquery.fancybox.pack.js
Generating.---- 30.00% (6/20)readable:C:\Dev\hexo-blog\themes\light\source\js\gallery.js
Generating.---- 35.00% (7/20)readable:C:\Dev\hexo-blog\themes\light\source\js\jquery.imagesloaded.min.js
Generating.---- 40.00% (8/20)readable:C:\Dev\hexo-blog\themes\light\source\js\moment.min.js
Generating.---- 45.00% (9/20)readable:C:\Dev\hexo-blog\themes\light\source\js\twitter.js
Generating.---- 50.00% (10/20)readable:C:\Dev\hexo-blog\themes\light\source\css\font\fontawesome-webfont.eot
Generating.---- 55.00% (11/20)readable:C:\Dev\hexo-blog\themes\light\source\css\font\fontawesome-webfont.svg
Generating.---- 60.00% (12/20)readable:C:\Dev\hexo-blog\themes\light\source\css\font\fontawesome-webfont.ttf
Generating.---- 65.00% (13/20)readable:C:\Dev\hexo-blog\themes\light\source\css\font\fontawesome-webfont.woff
Generating.---- 70.00% (14/20)not readable:C:\Dev\hexo-blog\public\index.html
Generating.---- 75.00% (15/20)not readable:C:\Dev\hexo-blog\public\0000/01/01/abcd/index.html
Generating.---- 80.00% (16/20)not readable:C:\Dev\hexo-blog\public\archives/index.html
Generating.---- 85.00% (17/20)not readable:C:\Dev\hexo-blog\public\archives/0/index.html
Generating.---- 90.00% (18/20)not readable:C:\Dev\hexo-blog\public\archives/0/01/index.html
empty

Generated completely.
Site generated in 0.374s.

我注意到最下面几个public文件夹里面的文件,路径有点怪异,比如:

Generating.---- 90.00% (18/20)not readable:C:\Dev\hexo-blog\public\archives/0/01/index.html

斜线和反斜线混合在用,这会不会是导致public下文件生成异常的原因呢?

@tommy351
Copy link
Member

@hhlux 而且日期似乎有異常?

@hhlux
Copy link
Author

hhlux commented Jan 20, 2013

对,日期有异常。昨天晚上更新到0.5.6后日期异常了,0.5.5以前没有发现日期错过。

@hhlux
Copy link
Author

hhlux commented Jan 20, 2013

我注意到一个地方,在C:\Users\heeefciy\AppData\Roaming\npm\node_modules\hexo\lib\cli\generate.js里

async.parallel([
    function(next){
      fs.exists(publicDir, function(exist){
        if (!exist) return next();
        file.empty(publicDir, keys.concat(cache), next);
        console.log(keys.concat)
        console.log("--------Empty-------- " + publicDir);
      });
    },
    function(next){
      var queue = async.queue(function(key, next){
        list[key](function(err, result){

async.parallel下两个方法,第一个是清除public文件夹,第二个是创建public下的文件。用的async_parallel,在我这儿执行的情况是第二个方法执行快完了 的时候,第一个方法开始执行,清除了刚刚创建的大部分文件。

如果把async.parallel换成async.series,下面两边方法会顺序执行,先清除再创建,就不会有我遇到的那个问题了。

看到这里,我的理解是async,parallel是异步执行下面的几个方法,执行顺序是不可知的。但是为什么别人的电脑执行结果都是正常的,我这边执行不正常?难道是CPU的问题?不知道我的理解正不正确,这个地方是不是应该改成顺序执行呢?

@ghost
Copy link

ghost commented Jan 22, 2013

貌似我也遇到了同样的问题,tags目录和archives只能存在一个目录,hexo generate一下,只有tags目录,无archives目录,再generate一下,只有archives目录,没有tags目录,搞不明白咯

@hhlux
Copy link
Author

hhlux commented Jan 22, 2013

@unclepulp 你的问题和我这个问题是一类的,我也遇到过。在tags和archives两个目录同时存在的时候,你手动删除其中一个目录,再执行generate,就能重现你这个问题了:交替生成,只能存其一。

我的理解是:generate的操作包含有两步,在public下第一步先删除,第二步再生成,应该是顺序执行。但貌似这两步现在是在并行执行(parallel),谁先谁后都未可知,所以会产生你我遇到的问题。

@rose1988c
Copy link

me too。 在win7下,Ubuntu好像没有这个问题

还有 .deploy 不能删,一删就惨了,找不到 .GIT,只能new一个新的了

@rose1988c
Copy link

1
2
3

@tommy351
Copy link
Member

發現原因,刪除時路徑中的/未被轉換成\,導致檔案遭到刪除,已在0.5.8版中修復,順便修復了生成進度顯示錯誤的問題

@xjvf
Copy link

xjvf commented May 31, 2018

完全不能生成index,不能deploy,也不能用server。但是同环境相同设置下其它的repo都正常生成。。。
崩溃了
[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants