<commit_before>#!/usr/bin/env bash

function die() {
  echo $*
  exit 1
}

if [ $# -ne "3" ]
then
    die "$0: Received $# args... dir, name, and name of latest file (latest.dmg) required"
fi
dir=$1
name=$2
latestName=$3

bucket=lantern
url=http://$bucket.s3.amazonaws.com/$name
echo "Uploading to http://cdn.getlantern.org/$name..."
aws -putp $bucket $name
echo "Uploaded lantern to http://cdn.getlantern.org/$name"
echo "Also available at $url"


pushd install/$dir || die "Could not change directories"
perl -pi -e "s;url_token;$url;g" $latestName || die "Could not replace URL token"
# Here's the trick -- send a custom mime type that's html instead of the mime type for the file extension
aws -putpm $bucket $latestName text/html || die "Could not upload latest?"
git checkout $latestName || die "Could not checkout"
popd

shasum $name | cut -d " " -f 1 > $latestName.sha1
aws -putp $bucket $latestName.sha1<commit_msg>Added sanity check for swapped version<commit_after>#!/usr/bin/env bash

function die() {
  echo $*
  exit 1
}

if [ $# -ne "3" ]
then
    die "$0: Received $# args... dir, name, and name of latest file (latest.dmg) required"
fi
dir=$1
name=$2
latestName=$3

bucket=lantern
url=http://$bucket.s3.amazonaws.com/$name
echo "Uploading to http://cdn.getlantern.org/$name..."
aws -putp $bucket $name
echo "Uploaded lantern to http://cdn.getlantern.org/$name"
echo "Also available at $url"


pushd install/$dir || die "Could not change directories"
perl -pi -e "s;url_token;$url;g" $latestName || die "Could not replace URL token"

# Makes sure it actually was replaced
grep $url $latestName || die "Something went wrong with creating latest dummy file"

# Here's the trick -- send a custom mime type that's html instead of the mime type for the file extension
aws -putpm $bucket $latestName text/html || die "Could not upload latest?"

git checkout $latestName || die "Could not checkout"
popd

shasum $name | cut -d " " -f 1 > $latestName.sha1
aws -putp $bucket $latestName.sha1
{'fraction_non_alphanumeric': 0.13363363363363365, 'fraction_numerical': 0.01001001001001001, 'mean_word_length': 4.035264483627204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3271662', 'n_tokens_mistral': 694, 'n_tokens_neox': 663, 'n_words': 250}