]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/mime.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 9 Jan 2018 03:19:03 +0000 (03:19 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 9 Jan 2018 03:19:03 +0000 (03:19 +0000)
lib/postgres/mime.sql

index d4bdd32ef6ec09b4c80ca000c79372542ece68ad..e5d1130975451b1937ba978481ace2f5a368d0de 100644 (file)
@@ -9,27 +9,6 @@ CREATE INDEX IF NOT EXISTS mime_ext_idx ON mime (ext);
 BEGIN TRANSACTION;
 CREATE TEMPORARY TABLE tmp_mime ON COMMIT DROP AS SELECT * FROM mime LIMIT 0;
 
-COPY mime FROM PROGRAM 'true || curl -s \
-https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types \
-| tr -d "\n" \
-| sed -E "s,^(.*?)<table[^>]+>(.*?)</table>(.*?)$,\2," \
-| sed "s/<.tr>/\n/g" \
-| grep "<td" \
-| sed "s,<td>,\t,g" \
-| sed -E -e "s/ *<br[^>]*> */,/g" -e "s/,[^\t]+//" -e "s, *<[^>]+> *,,g" -e "s/^[\t ]*//" -e "s/([^\t]+)\t([^\t]+)$/\2\t\1/" \
-| perl -pe "0 and /^([^\t]+,[^\t]+)/ and @_=split(qq|,|,\$_) and s/^[^\t]+/join(qq|,|,sort {length(\$b)<=>length(\$a)} @_)/e" \
-
-' WITH (format 'text', NULL '');
-
-DELETE FROM tmp_mime;
-COPY tmp_mime FROM PROGRAM 'true || curl -s \
-https://gist.githubusercontent.com/electerious/3d5a31a73cfd6423f835c074ab25fc06/raw/d48b8410e9aa6746cfd946bca21a1bb54c351c4e/Caddyfile \
-| sed -e "s/^ *//" -e "/^[^\.]/d" -e "s/ /\t/" -e "s/$/\t/" \
-' WITH (format 'text', NULL '');
-INSERT INTO mime SELECT * FROM tmp_mime ON CONFLICT DO NOTHING;
-
-UPDATE mime SET ext = REPLACE(ext,'.','') WHERE ext LIKE '.%';
-
 COPY mime FROM STDIN WITH (format 'text', NULL '');
 x3d    application/vnd.hzn-3d-crossword        3D Crossword Plugin
 3g2    video/3gpp2     3GP2
@@ -718,4 +697,24 @@ zir        application/vnd.zul     Z.U.L. Geometry
 zmm    application/vnd.handheld-entertainment+xml      ZVUE Media Manager
 zaz    application/vnd.zzazz.deck+xml  Zzazz Deck
 \.
+
+DELETE FROM tmp_mime;
+COPY tmp_mime FROM PROGRAM 'true && curl -s \
+https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types \
+| tr -d "\n" \
+| sed -E "s,^(.*?)<table[^>]+>(.*?)</table>(.*?)$,\2," \
+| sed "s/<.tr>/\n/g" \
+| grep "<td" \
+| sed "s,<td>,\t,g" \
+| sed -E -e "s/ *<br[^>]*> */,/g" -e "s/,[^\t]+//" -e "s, *<[^>]+> *,,g" -e "s/^[\t ]*//" -e "s/([^\t]+)\t([^\t]+)$/\2\t\1/" \
+| perl -pe "0 and /^([^\t]+,[^\t]+)/ and @_=split(qq|,|,\$_) and s/^[^\t]+/join(qq|,|,sort {length(\$b)<=>length(\$a)} @_)/e" \
+' WITH (format 'text', NULL '');
+INSERT INTO mime SELECT * FROM tmp_mime ON CONFLICT DO NOTHING;
+
+DELETE FROM tmp_mime;
+COPY tmp_mime FROM PROGRAM 'true && curl -s \
+https://gist.githubusercontent.com/electerious/3d5a31a73cfd6423f835c074ab25fc06/raw/d48b8410e9aa6746cfd946bca21a1bb54c351c4e/Caddyfile \
+| sed -e "s/^ *//" -e "/^[^\.]/d" -e "s/ /\t/" -e "s/$/\t/" -e "s/^\.//" \
+' WITH (format 'text', NULL '');
+INSERT INTO mime SELECT * FROM tmp_mime ON CONFLICT DO NOTHING;
 COMMIT;