Skip to content

Commit e275ad4

Browse files
committed
Update for Crystal v1.0.0
1 parent c363681 commit e275ad4

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs:
33
build:
44
working_directory: ~/app
55
docker:
6-
- image: crystallang/crystal:0.35.0
6+
- image: crystallang/crystal:1.0.0
77
steps:
88
- checkout
99
- run:

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
crystal 1.0.0

shard.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: rucksack
2-
version: 1.0.6
2+
version: 2.0.0
33
description: Attach static files to your compiled crystal binary and access them at runtime.
44

55
authors:
66
77

8-
crystal: 0.35.0
8+
crystal: ">= 1.0.0"
99

1010
license: MIT
1111

src/rucksack.cr

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Rucksack
2020
DATA_FILE = Process.executable_path.not_nil!
2121
MODE = ENV.fetch("RUCKSACK_MODE", "0").to_i
2222

23-
@@offset : UInt64 = 0
23+
@@offset : Int64 = 0
2424
@@index = {} of String => File
2525

2626
def self.offset
@@ -70,7 +70,7 @@ class Rucksack
7070

7171
raise RucksackEmpty.new("Rucksack is empty, did you pack any files?") if offset + 2 > eof
7272

73-
file_offset : UInt64 = 0.to_u64
73+
file_offset : Int64 = 0.to_i64
7474
::File.open(Process.executable_path.not_nil!) do |fd|
7575
fd.seek(offset)
7676
loop do
@@ -79,7 +79,7 @@ class Rucksack
7979
path = Bytes.new(path_len)
8080
fd.read(path)
8181

82-
size = fd.read_bytes(UInt64, IO::ByteFormat::LittleEndian)
82+
size = fd.read_bytes(Int64, IO::ByteFormat::LittleEndian)
8383
fd.seek(offset + file_offset + 2 + path_len + 8 + size)
8484

8585
body_digest = Bytes.new(32)
@@ -153,7 +153,7 @@ class Rucksack
153153
abstract class File
154154
abstract def read(io : IO, skip_verify = false)
155155
abstract def path : String
156-
abstract def size : UInt64
156+
abstract def size : Int64
157157
abstract def checksum : Slice(UInt8)
158158
end
159159

@@ -177,17 +177,17 @@ class Rucksack
177177
c.final
178178
end
179179

180-
def size : UInt64
180+
def size : Int64
181181
::File.size(@path)
182182
end
183183
end
184184

185185
class RucksackFile < File
186186
getter path : String
187187
getter checksum : Slice(UInt8)
188-
getter size : UInt64
188+
getter size : Int64
189189

190-
def initialize(@path, @offset : UInt64, @size, @checksum)
190+
def initialize(@path, @offset : Int64, @size, @checksum)
191191
@verified = false
192192
end
193193

@@ -217,7 +217,7 @@ macro rucksack(path)
217217
{{
218218
system(<<-EOC
219219
cat >#{__DIR__}/.rucksack_packer.cr <<EOF
220-
require "openssl"
220+
require "digest"
221221
222222
EOF_DELIM = "RS".to_slice
223223
@@ -233,7 +233,7 @@ dst = File.open(".rucksack", "a")
233233
src = File.open ARGV[0]
234234
size = src.size
235235
236-
dio = OpenSSL::DigestIO.new(dst, "SHA256", mode: OpenSSL::DigestIO::DigestMode::Write)
236+
dio = IO::Digest.new(dst, Digest::SHA256.new, mode: IO::Digest::DigestMode::Write)
237237
238238
dst.write_bytes ARGV[0].size.to_u16, IO::ByteFormat::LittleEndian
239239
dst.write(ARGV[0].to_slice)
@@ -242,7 +242,7 @@ dst.write_bytes size.to_u64, IO::ByteFormat::LittleEndian
242242
243243
bytes_copied = IO.copy(src, dio)
244244
245-
dst.write(dio.digest)
245+
dst.write(dio.final)
246246
dst.write(EOF_DELIM)
247247
248248
if bytes_copied != size

0 commit comments

Comments
 (0)