Skip to content

Commit 88fce82

Browse files
committed
Merge pull request code-dot-org#8332 from code-dot-org/levelSourceScript
Creates the bin/oneoff directory and adds invalidate_level_source_images.
2 parents 1f6c4a6 + 45af275 commit 88fce82

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

bin/oneoff/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This directory is intended as a repository of scripts having some (at most)
2+
short lived purpose. Any scripts having ongoing value should reside elsewhere.
3+
4+
Since many of these scripts would be harmful if accidentally run, consider
5+
chmod'ing them without the executable bit set.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env ruby
2+
# Found on production-console in May 2016, with no knowledge beyond its
3+
# contents.
4+
# ubuntu@production-console:~$ ls -l invalidate_level_source_images
5+
# -rw-r--r-- 1 ubuntu ubuntu 845 Nov 25 2014 invalidate_level_source_images
6+
7+
require_relative '../../config/environment'
8+
9+
# invalidate level_source_images by breaking the md5. Future solutions
10+
# will now create a new LevelSource because it can't find the existing
11+
# one.
12+
13+
# Some bad level_source_images may have been created before this bug
14+
# was fixed:
15+
# https://github.com/code-dot-org/code-dot-org/commit/1db0dfffb2c1a3634d467b67138b31eb3de257b9
16+
# we want to change the urls (eg: http://studio.code.org/sh/47434474/)
17+
# by generating a new level source id (instead of just fixing the
18+
# image) because facebook hangs on to images in the cache for too
19+
# long.
20+
21+
LevelSource.where(level_id: Script.find_by_name('frozen').level_ids).
22+
where('created_at < ?', '2014-11-20').each do |level_source|
23+
new_md5 = ("invalid-" + level_source.md5).slice(0..31)
24+
level_source.update_attribute(:md5, new_md5)
25+
end

0 commit comments

Comments
 (0)