File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ def to_emoji
52
52
end
53
53
end . parse! ( option_array )
54
54
55
- if $debug_mode
55
+ def reset_marshal_cache
56
56
File . open ( MARSHAL_TMP_FILE , File ::RDWR |File ::CREAT , 0644 ) do |f |
57
57
fc = {
58
58
'search_strings' => { } ,
@@ -84,8 +84,13 @@ def to_emoji
84
84
f . write ( Marshal . dump ( fc ) )
85
85
f . flush
86
86
f . truncate ( f . pos )
87
+ fc
87
88
end
89
+ end
88
90
91
+ if $debug_mode
92
+ reset_marshal_cache
93
+ STDERR . puts "Marshal cache reset!"
89
94
puts JSON . pretty_generate ( {
90
95
:items => [
91
96
{
@@ -99,7 +104,12 @@ def to_emoji
99
104
exit 0
100
105
end
101
106
102
- EMOJI_OBJ = File . open ( MARSHAL_TMP_FILE , File ::RDWR |File ::CREAT , 0644 ) { |f | Marshal . load ( f . read ) }
107
+ EMOJI_OBJ = begin
108
+ File . open ( MARSHAL_TMP_FILE , File ::RDWR |File ::CREAT , 0644 ) { |f | Marshal . load ( f . read ) }
109
+ rescue ArgumentError
110
+ STDERR . puts "Marshal cache could not be loaded. Resetting!"
111
+ reset_marshal_cache
112
+ end
103
113
104
114
### SEARCH SHIT
105
115
You can’t perform that action at this time.
0 commit comments