Commit 060175d
authored
Save local key-value store records with the correct extension (#91)
There was a bug that files in local key-value store were saved with the
wrong extension, e.g. `Actor.set_value('image.png', data)` would save
the record as `image.png.bin`.
This fixes it by making the filename generation more sensible:
- the `.bin` extension won't be added anymore if the content type is
`application/octet-stream`.
- the record metadata is no longer saved as
`{record_key}.__metadata__.json`, but as
`{record_filename}.__metadata__.json`
- this makes it a lot easier to find the right metadata for a given file
when opening the store
- the metadata no longer contains the `extension` attribute, just the
key
- the internal record representation now contains the `filename`
attribute pointing to the filename under which the record is saved.
I think the logic is a bit more readable this way, and it works better.
I also wrote a lot of tests to check if it works correctly, they're a
bit hacky, but good enough.
Fixes #85.1 parent 7826a38 commit 060175d
File tree
4 files changed
+305
-162
lines changed- src/apify/_memory_storage
- resource_clients
- tests/unit/memory_storage/resource_clients
4 files changed
+305
-162
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | 44 | | |
84 | 45 | | |
85 | 46 | | |
| |||
0 commit comments