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

Correct using createSha1Hash() with pipe() #4323

Merged
merged 1 commit into from
May 20, 2020

Conversation

seaoak
Copy link
Member

@seaoak seaoak commented May 20, 2020

What does it do?

Fix errors of the issue #3818. (#3818 (comment))

Supersede the draft PR #4292.

With Node.js v10.x (not v12.x), npm test fails some times.
One of them is process() - skip (mtime changed but hash matched): as follows:

  1) Hexo
       Box
         Box
           process() - skip (mtime changed but hash matched):
     AssertError: expected spy to be called with match
[_File] {
  params: {  },
  path: "a.txt",
  source: "J:\00_Seaoak\hexo\test\scripts\box\box_tmp\test\a.txt",
  type: "update"
} { path: "a.txt", type: "skip" }
      at Object.fail (J:\00_Seaoak\hexo\node_modules\sinon\lib\sinon\assert.js:107:21)
      at failAssertion (J:\00_Seaoak\hexo\node_modules\sinon\lib\sinon\assert.js:66:16)
      at Object.assert.(anonymous function) [as calledWithMatch] (J:\00_Seaoak\hexo\node_modules\sinon\lib\sinon\assert.js:92:13)
      at Context.it (J:\00_Seaoak\hexo\test\scripts\box\box.js:160:17)

Another one of them is update theme source files: as follows:

  2) Hexo
       Console
         generate
           update theme source files:

      AssertionError: expected 'b' to deeply equal 'bb'
      + expected - actual

      -b
      +bb

      at Context.it (J:\00_Seaoak\hexo\test\scripts\console\generate.js:207:22)

This patch fixes these errors.

I found that a combination Stream.readable.pipe() and Crypt.createHash() causes this error.
As shown by the @segayuu 's comment (#4292 (comment)),
Hash#digest() can not be used in the finish event of Hash#pipe().

This patch uses the data event of Hash#pipe() to get hash buffer,
and uses Buffer#toString('hex') to get digest value from the buffer.

How to test

nvm use 10.20.1
git clone -b correct_using_createSha1Hash_with_pipe https://github.com/seaoak/hexo.git
cd hexo
npm install
npm test

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 97.745% when pulling b362ac4 on seaoak:correct_using_createSha1Hash_with_pipe into 378c22b on hexojs:master.

@seaoak seaoak requested review from segayuu and SukkaW May 20, 2020 03:52
Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@segayuu segayuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@seaoak seaoak merged commit 8512f07 into hexojs:master May 20, 2020
@joseyusunsuaira
Copy link

joseyusunsuaira commented Sep 9, 2023

Buenas noches profesor

trabajo de
jose favian yusunguaira
carlos felipe amaya
juan diego aragonez
erick felipe carvajal
jhonatan murcia

music.play(music.string_playable("A F E F D G E F ", 120),
    music.PlaybackMode.UNTIL_DONE)

basic.show_leds("""giro = 0
if (0) == (9):
giro = 6
music.play(music.string_playable("A F E F D G E F ", 120),
music.PlaybackMode.UNTIL_DONE)
basic.show_leds("""
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #
""")
basic.show_leds("""
. . . . .
. # # # .
. # . # .
. # # # .
. . . . .
""")
basic.show_leds("""
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
""")
basic.show_leds("""
# . . . #
# . . . #
# . . . #
. # . # .
. . # . .
""")
basic.show_leds("""
. . # . .
. # . # .
# . . . #
# . . . #
# . . . #
""")
basic.pause(500)
basic.show_leds("""
# # # # #
. . . # .
. . # . .
. # . . .
# # # # #
""")
basic.show_leds("""
# . # # .
# . # # .
# . # # .
# . # # .
# # # # #
""")
basic.show_leds("""
# # . . #
# # . # .
# . . # .
# . . # .
# # # # .
""")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants