Artifact ffc8251555af50947b4244716263fc66217ce32e:
File
src/shun.c
part of check-in
[80406199683a]
- Fix the Setup->Shunned->Rebuild button so that it works when the
"fossil ui" command is run from within a check-out and without specifying
the repository filename.
by
drh on
2008-11-27 22:58:53.
0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20 /*.** Copyright
0010: 28 63 29 20 32 30 30 38 20 44 2e 20 52 69 63 68 (c) 2008 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 0a 2a 2a 20 54 ard Hipp.**.** T
0030: 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66 his program is f
0040: 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f ree software; yo
0050: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75 u can redistribu
0060: 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 2a 2a 20 te it and/or.**
0070: 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 65 72 20 modify it under
0080: 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65 the terms of the
0090: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62 GNU General Pub
00a0: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 76 lic.** License v
00b0: 65 72 73 69 6f 6e 20 32 20 61 73 20 70 75 62 6c ersion 2 as publ
00c0: 69 73 68 65 64 20 62 79 20 74 68 65 20 46 72 65 ished by the Fre
00d0: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 e Software Found
00e0: 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 ation..**.** Thi
00f0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73 s program is dis
0100: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 tributed in the
0110: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c hope that it wil
0120: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 2a 2a 20 l be useful,.**
0130: 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20 but WITHOUT ANY
0140: 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75 WARRANTY; withou
0150: 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69 t even the impli
0160: 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 2a ed warranty of.*
0170: 2a 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 * MERCHANTABILIT
0180: 59 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 Y or FITNESS FOR
0190: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 A PARTICULAR PU
01a0: 52 50 4f 53 45 2e 20 20 53 65 65 20 74 68 65 20 RPOSE. See the
01b0: 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 61 6c 20 50 GNU.** General P
01c0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f ublic License fo
01d0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a r more details..
01e0: 2a 2a 20 0a 2a 2a 20 59 6f 75 20 73 68 6f 75 6c ** .** You shoul
01f0: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20 d have received
0200: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e a copy of the GN
0210: 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 U General Public
0220: 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e .** License alon
0230: 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 62 72 g with this libr
0240: 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69 ary; if not, wri
0250: 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 46 72 65 te to the.** Fre
0260: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 e Software Found
0270: 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 20 ation, Inc., 59
0280: 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 53 Temple Place - S
0290: 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 42 6f 73 uite 330,.** Bos
02a0: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31 ton, MA 02111-1
02b0: 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 2a 2a 20 307, USA..**.**
02c0: 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69 Author contact i
02d0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a 2a 20 20 nformation:.**
02e0: 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a 2a drh@hwaci.com.*
02f0: 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68 * http://www.h
0300: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 2a 2a waci.com/drh/.**
0310: 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a .***************
0320: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0330: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0340: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0350: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0360: 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 66 69 6c 65 .**.** This file
0370: 20 63 6f 6e 74 61 69 6e 73 20 63 6f 64 65 20 75 contains code u
0380: 73 65 64 20 74 6f 20 6d 61 6e 61 67 65 20 53 48 sed to manage SH
0390: 55 4e 20 74 61 62 6c 65 20 6f 66 20 74 68 65 20 UN table of the
03a0: 72 65 70 6f 73 69 74 6f 72 79 0a 2a 2f 0a 23 69 repository.*/.#i
03b0: 6e 63 6c 75 64 65 20 22 63 6f 6e 66 69 67 2e 68 nclude "config.h
03c0: 22 0a 23 69 6e 63 6c 75 64 65 20 22 73 68 75 6e ".#include "shun
03d0: 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73 .h".#include <as
03e0: 73 65 72 74 2e 68 3e 0a 0a 2f 2a 0a 2a 2a 20 52 sert.h>../*.** R
03f0: 65 74 75 72 6e 20 74 72 75 65 20 69 66 20 74 68 eturn true if th
0400: 65 20 67 69 76 65 6e 20 55 55 49 44 20 73 68 6f e given UUID sho
0410: 75 6c 64 20 62 65 20 73 68 75 6e 6e 65 64 2e 0a uld be shunned..
0420: 2a 2f 0a 69 6e 74 20 75 75 69 64 5f 69 73 5f 73 */.int uuid_is_s
0430: 68 75 6e 6e 65 64 28 63 6f 6e 73 74 20 63 68 61 hunned(const cha
0440: 72 20 2a 7a 55 75 69 64 29 7b 0a 20 20 73 74 61 r *zUuid){. sta
0450: 74 69 63 20 53 74 6d 74 20 71 3b 0a 20 20 69 6e tic Stmt q;. in
0460: 74 20 72 63 3b 0a 20 20 69 66 28 20 7a 55 75 69 t rc;. if( zUui
0470: 64 3d 3d 30 20 7c 7c 20 7a 55 75 69 64 5b 30 5d d==0 || zUuid[0]
0480: 3d 3d 30 20 29 20 72 65 74 75 72 6e 20 30 3b 0a ==0 ) return 0;.
0490: 20 20 64 62 5f 73 74 61 74 69 63 5f 70 72 65 70 db_static_prep
04a0: 61 72 65 28 26 71 2c 20 22 53 45 4c 45 43 54 20 are(&q, "SELECT
04b0: 31 20 46 52 4f 4d 20 73 68 75 6e 20 57 48 45 52 1 FROM shun WHER
04c0: 45 20 75 75 69 64 3d 3a 75 75 69 64 22 29 3b 0a E uuid=:uuid");.
04d0: 20 20 64 62 5f 62 69 6e 64 5f 74 65 78 74 28 26 db_bind_text(&
04e0: 71 2c 20 22 3a 75 75 69 64 22 2c 20 7a 55 75 69 q, ":uuid", zUui
04f0: 64 29 3b 0a 20 20 72 63 20 3d 20 64 62 5f 73 74 d);. rc = db_st
0500: 65 70 28 26 71 29 3b 0a 20 20 64 62 5f 72 65 73 ep(&q);. db_res
0510: 65 74 28 26 71 29 3b 0a 20 20 72 65 74 75 72 6e et(&q);. return
0520: 20 72 63 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 3b rc==SQLITE_ROW;
0530: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 57 45 42 50 41 47 .}../*.** WEBPAG
0540: 45 3a 20 73 68 75 6e 0a 2a 2f 0a 76 6f 69 64 20 E: shun.*/.void
0550: 73 68 75 6e 5f 70 61 67 65 28 76 6f 69 64 29 7b shun_page(void){
0560: 0a 20 20 53 74 6d 74 20 71 3b 0a 20 20 69 6e 74 . Stmt q;. int
0570: 20 63 6e 74 20 3d 20 30 3b 0a 20 20 63 6f 6e 73 cnt = 0;. cons
0580: 74 20 63 68 61 72 20 2a 7a 55 75 69 64 20 3d 20 t char *zUuid =
0590: 50 28 22 75 75 69 64 22 29 3b 0a 20 20 69 6e 74 P("uuid");. int
05a0: 20 6e 55 75 69 64 3b 0a 20 20 63 68 61 72 20 7a nUuid;. char z
05b0: 43 61 6e 6f 6e 69 63 61 6c 5b 55 55 49 44 5f 53 Canonical[UUID_S
05c0: 49 5a 45 2b 31 5d 3b 0a 0a 20 20 6c 6f 67 69 6e IZE+1];.. login
05d0: 5f 63 68 65 63 6b 5f 63 72 65 64 65 6e 74 69 61 _check_credentia
05e0: 6c 73 28 29 3b 0a 20 20 69 66 28 20 21 67 2e 6f ls();. if( !g.o
05f0: 6b 41 64 6d 69 6e 20 29 7b 0a 20 20 20 20 6c 6f kAdmin ){. lo
0600: 67 69 6e 5f 6e 65 65 64 65 64 28 29 3b 0a 20 20 gin_needed();.
0610: 7d 0a 20 20 69 66 28 20 50 28 22 72 65 62 75 69 }. if( P("rebui
0620: 6c 64 22 29 20 29 7b 0a 20 20 20 20 64 62 5f 63 ld") ){. db_c
0630: 6c 6f 73 65 28 29 3b 0a 20 20 20 20 64 62 5f 6f lose();. db_o
0640: 70 65 6e 5f 72 65 70 6f 73 69 74 6f 72 79 28 67 pen_repository(g
0650: 2e 7a 52 65 70 6f 73 69 74 6f 72 79 4e 61 6d 65 .zRepositoryName
0660: 29 3b 0a 20 20 20 20 64 62 5f 62 65 67 69 6e 5f );. db_begin_
0670: 74 72 61 6e 73 61 63 74 69 6f 6e 28 29 3b 0a 20 transaction();.
0680: 20 20 20 72 65 62 75 69 6c 64 5f 64 62 28 30 2c rebuild_db(0,
0690: 30 29 3b 0a 20 20 20 20 64 62 5f 65 6e 64 5f 74 0);. db_end_t
06a0: 72 61 6e 73 61 63 74 69 6f 6e 28 30 29 3b 0a 20 ransaction(0);.
06b0: 20 7d 0a 20 20 69 66 28 20 7a 55 75 69 64 20 29 }. if( zUuid )
06c0: 7b 0a 20 20 20 20 6e 55 75 69 64 20 3d 20 73 74 {. nUuid = st
06d0: 72 6c 65 6e 28 7a 55 75 69 64 29 3b 0a 20 20 20 rlen(zUuid);.
06e0: 20 69 66 28 20 6e 55 75 69 64 21 3d 34 30 20 7c if( nUuid!=40 |
06f0: 7c 20 21 76 61 6c 69 64 61 74 65 31 36 28 7a 55 | !validate16(zU
0700: 75 69 64 2c 20 6e 55 75 69 64 29 20 29 7b 0a 20 uid, nUuid) ){.
0710: 20 20 20 20 20 7a 55 75 69 64 20 3d 20 30 3b 0a zUuid = 0;.
0720: 20 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 }else{.
0730: 20 6d 65 6d 63 70 79 28 7a 43 61 6e 6f 6e 69 63 memcpy(zCanonic
0740: 61 6c 2c 20 7a 55 75 69 64 2c 20 55 55 49 44 5f al, zUuid, UUID_
0750: 53 49 5a 45 2b 31 29 3b 0a 20 20 20 20 20 20 63 SIZE+1);. c
0760: 61 6e 6f 6e 69 63 61 6c 31 36 28 7a 43 61 6e 6f anonical16(zCano
0770: 6e 69 63 61 6c 2c 20 55 55 49 44 5f 53 49 5a 45 nical, UUID_SIZE
0780: 29 3b 0a 20 20 20 20 20 20 7a 55 75 69 64 20 3d );. zUuid =
0790: 20 7a 43 61 6e 6f 6e 69 63 61 6c 3b 0a 20 20 20 zCanonical;.
07a0: 20 7d 0a 20 20 7d 0a 20 20 73 74 79 6c 65 5f 68 }. }. style_h
07b0: 65 61 64 65 72 28 22 53 68 75 6e 6e 65 64 20 41 eader("Shunned A
07c0: 72 74 69 66 61 63 74 73 22 29 3b 0a 20 20 69 66 rtifacts");. if
07d0: 28 20 7a 55 75 69 64 20 26 26 20 50 28 22 73 75 ( zUuid && P("su
07e0: 62 22 29 20 29 7b 0a 20 20 20 20 6c 6f 67 69 6e b") ){. login
07f0: 5f 76 65 72 69 66 79 5f 63 73 72 66 5f 73 65 63 _verify_csrf_sec
0800: 72 65 74 28 29 3b 0a 20 20 20 20 64 62 5f 6d 75 ret();. db_mu
0810: 6c 74 69 5f 65 78 65 63 28 22 44 45 4c 45 54 45 lti_exec("DELETE
0820: 20 46 52 4f 4d 20 73 68 75 6e 20 57 48 45 52 45 FROM shun WHERE
0830: 20 75 75 69 64 3d 27 25 73 27 22 2c 20 7a 55 75 uuid='%s'", zUu
0840: 69 64 29 3b 0a 20 20 20 20 69 66 28 20 64 62 5f id);. if( db_
0850: 65 78 69 73 74 73 28 22 53 45 4c 45 43 54 20 31 exists("SELECT 1
0860: 20 46 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45 FROM blob WHERE
0870: 20 75 75 69 64 3d 27 25 73 27 22 2c 20 7a 55 75 uuid='%s'", zUu
0880: 69 64 29 20 29 7b 0a 20 20 20 20 20 20 40 20 3c id) ){. @ <
0890: 70 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 62 p><font color="b
08a0: 6c 75 65 22 3e 41 72 74 69 66 61 63 74 20 0a 20 lue">Artifact .
08b0: 20 20 20 20 20 40 20 3c 61 20 68 72 65 66 3d 22 @ <a href="
08c0: 25 73 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 %s(g.zBaseURL)/a
08d0: 72 74 69 66 61 63 74 2f 25 73 28 7a 55 75 69 64 rtifact/%s(zUuid
08e0: 29 22 3e 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e )">%s(zUuid)</a>
08f0: 20 69 73 20 6e 6f 0a 20 20 20 20 20 20 40 20 6c is no. @ l
0900: 6f 6e 67 65 72 20 62 65 69 6e 67 20 73 68 75 6e onger being shun
0910: 6e 65 64 2e 3c 2f 66 6f 6e 74 3e 3c 2f 70 3e 0a ned.</font></p>.
0920: 20 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 }else{.
0930: 20 40 20 3c 70 3e 3c 66 6f 6e 74 20 63 6f 6c 6f @ <p><font colo
0940: 72 3d 22 62 6c 75 65 22 3e 41 72 74 69 66 61 63 r="blue">Artifac
0950: 74 20 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 20 t %s(zUuid)</a>
0960: 77 69 6c 6c 20 6e 6f 20 6c 6f 6e 67 65 72 0a 20 will no longer.
0970: 20 20 20 20 20 40 20 62 65 20 73 68 75 6e 6e 65 @ be shunne
0980: 64 2e 20 20 42 75 74 20 69 74 20 64 6f 65 73 20 d. But it does
0990: 6e 6f 74 20 65 78 69 73 74 20 69 6e 20 74 68 65 not exist in the
09a0: 20 72 65 70 6f 73 69 74 6f 72 79 2e 20 20 49 74 repository. It
09b0: 0a 20 20 20 20 20 20 40 20 6d 61 79 20 62 65 20 . @ may be
09c0: 6e 65 63 65 73 73 61 72 79 20 74 6f 20 72 65 62 necessary to reb
09d0: 75 69 6c 64 20 74 68 65 20 72 65 70 6f 73 69 74 uild the reposit
09e0: 6f 72 79 20 75 73 69 6e 67 20 74 68 65 0a 20 20 ory using the.
09f0: 20 20 20 20 40 20 3c 62 3e 66 6f 73 73 69 6c 20 @ <b>fossil
0a00: 72 65 62 75 69 6c 64 3c 2f 62 3e 20 63 6f 6d 6d rebuild</b> comm
0a10: 61 6e 64 2d 6c 69 6e 65 20 62 65 66 6f 72 65 20 and-line before
0a20: 74 68 65 20 61 72 74 69 66 61 63 74 20 63 6f 6e the artifact con
0a30: 74 65 6e 74 0a 20 20 20 20 20 20 40 20 63 61 6e tent. @ can
0a40: 20 70 75 6c 6c 65 64 20 69 6e 20 66 72 6f 6d 20 pulled in from
0a50: 6f 74 68 65 72 20 72 65 73 70 6f 73 69 74 6f 72 other respositor
0a60: 69 65 73 2e 3c 2f 66 6f 6e 74 3e 3c 2f 70 3e 0a ies.</font></p>.
0a70: 20 20 20 20 7d 0a 20 20 7d 0a 20 20 69 66 28 20 }. }. if(
0a80: 7a 55 75 69 64 20 26 26 20 50 28 22 61 64 64 22 zUuid && P("add"
0a90: 29 20 29 7b 0a 20 20 20 20 6c 6f 67 69 6e 5f 76 ) ){. login_v
0aa0: 65 72 69 66 79 5f 63 73 72 66 5f 73 65 63 72 65 erify_csrf_secre
0ab0: 74 28 29 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 t();. db_mult
0ac0: 69 5f 65 78 65 63 28 22 49 4e 53 45 52 54 20 4f i_exec("INSERT O
0ad0: 52 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 73 68 R IGNORE INTO sh
0ae0: 75 6e 20 56 41 4c 55 45 53 28 27 25 73 27 29 22 un VALUES('%s')"
0af0: 2c 20 7a 55 75 69 64 29 3b 0a 20 20 20 20 40 20 , zUuid);. @
0b00: 3c 70 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 <p><font color="
0b10: 62 6c 75 65 22 3e 41 72 74 69 66 61 63 74 0a 20 blue">Artifact.
0b20: 20 20 20 40 20 3c 61 20 68 72 65 66 3d 22 25 73 @ <a href="%s
0b30: 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 72 74 (g.zBaseURL)/art
0b40: 69 66 61 63 74 2f 25 73 28 7a 55 75 69 64 29 22 ifact/%s(zUuid)"
0b50: 3e 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 20 68 >%s(zUuid)</a> h
0b60: 61 73 20 62 65 65 6e 0a 20 20 20 20 40 20 73 68 as been. @ sh
0b70: 75 6e 6e 65 64 2e 20 20 49 74 20 77 69 6c 6c 20 unned. It will
0b80: 6e 6f 20 6c 6f 6e 67 65 72 20 62 65 20 70 75 73 no longer be pus
0b90: 68 65 64 2e 0a 20 20 20 20 40 20 49 74 20 77 69 hed.. @ It wi
0ba0: 6c 6c 20 62 65 20 72 65 6d 6f 76 65 64 20 66 72 ll be removed fr
0bb0: 6f 6d 20 74 68 65 20 72 65 70 6f 73 69 74 6f 72 om the repositor
0bc0: 79 20 74 68 65 20 6e 65 78 74 20 74 69 6d 65 20 y the next time
0bd0: 74 68 65 20 72 65 73 70 6f 73 69 74 6f 72 79 0a the respository.
0be0: 20 20 20 20 40 20 69 73 20 72 65 62 75 69 6c 74 @ is rebuilt
0bf0: 20 75 73 69 6e 67 20 74 68 65 20 3c 62 3e 66 6f using the <b>fo
0c00: 73 73 69 6c 20 72 65 62 75 69 6c 64 3c 2f 62 3e ssil rebuild</b>
0c10: 20 63 6f 6d 6d 61 6e 64 2d 6c 69 6e 65 3c 2f 66 command-line</f
0c20: 6f 6e 74 3e 3c 2f 70 3e 0a 20 20 7d 0a 20 20 40 ont></p>. }. @
0c30: 20 3c 70 3e 54 68 65 20 61 72 74 69 66 61 63 74 <p>The artifact
0c40: 73 20 6c 69 73 74 65 64 20 62 65 6c 6f 77 20 68 s listed below h
0c50: 61 76 65 20 62 65 65 6e 20 73 68 75 6e 6e 65 64 ave been shunned
0c60: 20 62 79 20 74 68 69 73 20 72 65 70 6f 73 69 74 by this reposit
0c70: 6f 72 79 2e 0a 20 20 40 20 54 68 69 73 20 6d 65 ory.. @ This me
0c80: 61 6e 73 20 74 68 61 74 20 74 68 65 20 61 72 74 ans that the art
0c90: 69 66 61 63 74 73 20 77 69 6c 6c 20 6e 6f 74 20 ifacts will not
0ca0: 62 65 20 74 72 61 6e 73 6d 69 74 74 65 64 20 6f be transmitted o
0cb0: 6e 20 61 20 70 75 73 68 20 6e 6f 72 0a 20 20 40 n a push nor. @
0cc0: 20 72 65 63 69 65 76 65 64 20 6f 6e 20 61 20 70 recieved on a p
0cd0: 75 6c 6c 2e 20 20 54 68 65 73 65 20 61 72 74 69 ull. These arti
0ce0: 66 61 63 74 73 20 61 72 65 20 62 61 6e 6e 65 64 facts are banned
0cf0: 20 66 72 6f 6d 20 74 68 65 20 72 65 73 70 6f 73 from the respos
0d00: 69 74 6f 72 79 2e 3c 2f 70 3e 0a 20 20 40 20 3c itory.</p>. @ <
0d10: 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 64 62 blockquote>. db
0d20: 5f 70 72 65 70 61 72 65 28 26 71 2c 20 0a 20 20 _prepare(&q, .
0d30: 20 20 20 22 53 45 4c 45 43 54 20 75 75 69 64 2c "SELECT uuid,
0d40: 20 45 58 49 53 54 53 28 53 45 4c 45 43 54 20 31 EXISTS(SELECT 1
0d50: 20 46 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45 FROM blob WHERE
0d60: 20 62 6c 6f 62 2e 75 75 69 64 3d 73 68 75 6e 2e blob.uuid=shun.
0d70: 75 75 69 64 29 22 0a 20 20 20 20 20 22 20 20 46 uuid)". " F
0d80: 52 4f 4d 20 73 68 75 6e 20 4f 52 44 45 52 20 42 ROM shun ORDER B
0d90: 59 20 75 75 69 64 22 29 3b 0a 20 20 77 68 69 6c Y uuid");. whil
0da0: 65 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d e( db_step(&q)==
0db0: 53 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 SQLITE_ROW ){.
0dc0: 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 55 const char *zU
0dd0: 75 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f uid = db_column_
0de0: 74 65 78 74 28 26 71 2c 20 30 29 3b 0a 20 20 20 text(&q, 0);.
0df0: 20 69 6e 74 20 73 74 69 6c 6c 45 78 69 73 74 73 int stillExists
0e00: 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 = db_column_int
0e10: 28 26 71 2c 20 31 29 3b 0a 20 20 20 20 63 6e 74 (&q, 1);. cnt
0e20: 2b 2b 3b 0a 20 20 20 20 69 66 28 20 73 74 69 6c ++;. if( stil
0e30: 6c 45 78 69 73 74 73 20 29 7b 0a 20 20 20 20 20 lExists ){.
0e40: 20 40 20 3c 62 3e 3c 61 20 68 72 65 66 3d 22 25 @ <b><a href="%
0e50: 73 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 72 s(g.zBaseURL)/ar
0e60: 74 69 66 61 63 74 2f 25 73 28 7a 55 75 69 64 29 tifact/%s(zUuid)
0e70: 22 3e 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 3c ">%s(zUuid)</a><
0e80: 2f 62 3e 3c 62 72 3e 0a 20 20 20 20 7d 65 6c 73 /b><br>. }els
0e90: 65 7b 0a 20 20 20 20 20 20 40 20 3c 62 3e 25 73 e{. @ <b>%s
0ea0: 28 7a 55 75 69 64 29 3c 2f 62 3e 3c 62 72 3e 0a (zUuid)</b><br>.
0eb0: 20 20 20 20 7d 0a 20 20 7d 0a 20 20 69 66 28 20 }. }. if(
0ec0: 63 6e 74 3d 3d 30 20 29 7b 0a 20 20 20 20 40 20 cnt==0 ){. @
0ed0: 3c 69 3e 6e 6f 20 61 72 74 69 66 61 63 74 73 20 <i>no artifacts
0ee0: 61 72 65 20 73 68 75 6e 6e 65 64 20 6f 6e 20 74 are shunned on t
0ef0: 68 69 73 20 73 65 72 76 65 72 3c 2f 69 3e 0a 20 his server</i>.
0f00: 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 }. db_finalize
0f10: 28 26 71 29 3b 0a 20 20 40 20 3c 2f 62 6c 6f 63 (&q);. @ </bloc
0f20: 6b 71 75 6f 74 65 3e 0a 20 20 40 20 3c 68 72 3e kquote>. @ <hr>
0f30: 0a 20 20 40 20 3c 61 20 6e 61 6d 65 3d 22 61 64 . @ <a name="ad
0f40: 64 73 68 75 6e 22 3e 3c 2f 61 3e 0a 20 20 40 20 dshun"></a>. @
0f50: 3c 70 3e 54 6f 20 73 68 75 6e 20 61 6e 20 61 72 <p>To shun an ar
0f60: 74 69 66 61 63 74 2c 20 65 6e 74 65 72 20 69 74 tifact, enter it
0f70: 73 20 55 55 49 44 20 69 6e 20 74 68 65 0a 20 20 s UUID in the.
0f80: 40 20 66 6f 6c 6c 6f 77 69 6e 67 20 62 6f 78 20 @ following box
0f90: 61 6e 64 20 70 72 65 73 73 20 74 68 65 20 22 53 and press the "S
0fa0: 68 75 6e 22 20 62 75 74 74 6f 6e 2e 20 20 54 68 hun" button. Th
0fb0: 69 73 20 77 69 6c 6c 20 63 61 75 73 65 20 74 68 is will cause th
0fc0: 65 20 61 72 74 69 66 61 63 74 0a 20 20 40 20 74 e artifact. @ t
0fd0: 6f 20 62 65 20 72 65 6d 6f 76 65 64 20 66 72 6f o be removed fro
0fe0: 6d 20 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79 m the repository
0ff0: 20 61 6e 64 20 77 69 6c 6c 20 70 72 65 76 65 6e and will preven
1000: 74 20 74 68 65 20 61 72 74 69 66 61 63 74 20 66 t the artifact f
1010: 72 6f 6d 20 62 65 69 6e 67 0a 20 20 40 20 72 65 rom being. @ re
1020: 61 64 64 65 64 20 74 6f 20 74 68 65 20 72 65 70 added to the rep
1030: 6f 73 69 74 6f 72 79 20 62 79 20 73 75 62 73 65 ository by subse
1040: 71 75 65 6e 74 20 73 79 6e 63 20 6f 70 65 72 61 quent sync opera
1050: 74 69 6f 6e 2e 3c 2f 70 3e 0a 20 20 40 0a 20 20 tion.</p>. @.
1060: 40 20 3c 70 3e 57 61 72 6e 69 6e 67 3a 20 20 53 @ <p>Warning: S
1070: 68 75 6e 6e 69 6e 67 20 73 68 6f 75 6c 64 20 6f hunning should o
1080: 6e 6c 79 20 62 65 20 75 73 65 64 20 74 6f 20 72 nly be used to r
1090: 65 6d 6f 76 65 20 69 6e 61 70 70 72 6f 70 72 69 emove inappropri
10a0: 61 74 65 20 63 6f 6e 74 65 6e 74 0a 20 20 40 20 ate content. @
10b0: 66 72 6f 6d 20 74 68 65 20 72 65 70 6f 73 69 74 from the reposit
10c0: 6f 72 79 2e 20 20 49 6e 61 70 70 72 6f 70 72 69 ory. Inappropri
10d0: 61 74 65 20 63 6f 6e 74 65 6e 74 20 69 6e 63 6c ate content incl
10e0: 75 64 65 73 20 73 75 63 68 20 74 68 69 6e 67 73 udes such things
10f0: 20 61 73 0a 20 20 40 20 73 70 61 6d 20 61 64 64 as. @ spam add
1100: 65 64 20 74 6f 20 57 69 6b 69 2c 20 66 69 6c 65 ed to Wiki, file
1110: 73 20 74 68 61 74 20 76 69 6f 6c 61 74 65 20 63 s that violate c
1120: 6f 70 79 72 69 67 68 74 20 6f 72 20 70 61 74 65 opyright or pate
1130: 6e 74 20 61 67 72 65 65 6d 65 6e 74 73 2c 0a 20 nt agreements,.
1140: 20 40 20 6f 72 20 61 72 74 69 66 61 63 74 73 20 @ or artifacts
1150: 74 68 61 74 20 62 79 20 64 65 73 69 67 6e 20 6f that by design o
1160: 72 20 61 63 63 69 64 65 6e 74 20 69 6e 74 65 72 r accident inter
1170: 66 65 72 65 20 77 69 74 68 20 74 68 65 20 70 72 fere with the pr
1180: 6f 63 65 73 73 69 6e 67 0a 20 20 40 20 6f 66 20 ocessing. @ of
1190: 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79 2e 20 the repository.
11a0: 20 44 6f 20 6e 6f 74 20 73 68 75 6e 20 61 72 74 Do not shun art
11b0: 69 66 61 63 74 73 20 6d 65 72 65 6c 79 20 74 6f ifacts merely to
11c0: 20 72 65 6d 6f 76 65 20 74 68 65 6d 20 66 72 6f remove them fro
11d0: 6d 0a 20 20 40 20 73 69 67 68 74 20 2d 20 73 65 m. @ sight - se
11e0: 74 20 74 68 65 20 22 68 69 64 64 65 6e 22 20 74 t the "hidden" t
11f0: 61 67 20 6f 6e 20 73 75 63 68 20 61 72 74 69 66 ag on such artif
1200: 61 63 74 73 20 69 6e 73 74 65 61 64 2e 3c 2f 70 acts instead.</p
1210: 3e 0a 20 20 40 20 0a 20 20 40 20 3c 62 6c 6f 63 >. @ . @ <bloc
1220: 6b 71 75 6f 74 65 3e 0a 20 20 40 20 3c 66 6f 72 kquote>. @ <for
1230: 6d 20 6d 65 74 68 6f 64 3d 22 50 4f 53 54 22 20 m method="POST"
1240: 61 63 74 69 6f 6e 3d 22 25 73 28 67 2e 7a 42 61 action="%s(g.zBa
1250: 73 65 55 52 4c 29 2f 25 73 28 67 2e 7a 50 61 74 seURL)/%s(g.zPat
1260: 68 29 22 3e 0a 20 20 6c 6f 67 69 6e 5f 69 6e 73 h)">. login_ins
1270: 65 72 74 5f 63 73 72 66 5f 73 65 63 72 65 74 28 ert_csrf_secret(
1280: 29 3b 0a 20 20 40 20 3c 69 6e 70 75 74 20 74 79 );. @ <input ty
1290: 70 65 3d 22 74 65 78 74 22 20 6e 61 6d 65 3d 22 pe="text" name="
12a0: 75 75 69 64 22 20 76 61 6c 75 65 3d 22 25 68 28 uuid" value="%h(
12b0: 50 44 28 22 73 68 75 6e 22 2c 22 22 29 29 22 20 PD("shun",""))"
12c0: 73 69 7a 65 3d 22 35 30 22 3e 0a 20 20 40 20 3c size="50">. @ <
12d0: 69 6e 70 75 74 20 74 79 70 65 3d 22 73 75 62 6d input type="subm
12e0: 69 74 22 20 6e 61 6d 65 3d 22 61 64 64 22 20 76 it" name="add" v
12f0: 61 6c 75 65 3d 22 53 68 75 6e 22 3e 0a 20 20 40 alue="Shun">. @
1300: 20 3c 2f 66 6f 72 6d 3e 0a 20 20 40 20 3c 2f 62 </form>. @ </b
1310: 6c 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 40 0a 20 lockquote>. @.
1320: 20 40 20 3c 70 3e 45 6e 74 65 72 20 74 68 65 20 @ <p>Enter the
1330: 55 55 49 44 20 6f 66 20 61 20 70 72 65 76 69 6f UUID of a previo
1340: 75 73 20 73 68 75 6e 6e 65 64 20 61 72 74 69 66 us shunned artif
1350: 61 63 74 20 74 6f 20 63 61 75 73 65 20 69 74 20 act to cause it
1360: 74 6f 20 62 65 0a 20 20 40 20 61 63 63 65 70 74 to be. @ accept
1370: 65 64 20 61 67 61 69 6e 20 69 6e 20 74 68 65 20 ed again in the
1380: 72 65 70 6f 73 69 74 6f 72 79 2e 20 20 54 68 65 repository. The
1390: 20 61 72 74 69 66 61 63 74 20 63 6f 6e 74 65 6e artifact conten
13a0: 74 20 69 73 20 6e 6f 74 0a 20 20 40 20 72 65 73 t is not. @ res
13b0: 74 6f 72 65 64 20 62 65 63 61 75 73 65 20 74 68 tored because th
13c0: 65 20 63 6f 6e 74 65 6e 74 20 69 73 20 75 6e 6b e content is unk
13d0: 6e 6f 77 6e 2e 20 20 54 68 65 20 6f 6e 6c 79 20 nown. The only
13e0: 63 68 61 6e 67 65 20 69 73 20 74 68 61 74 0a 20 change is that.
13f0: 20 40 20 74 68 65 20 66 6f 72 6d 65 72 6c 79 20 @ the formerly
1400: 73 68 75 6e 6e 65 64 20 61 72 74 69 66 61 63 74 shunned artifact
1410: 20 77 69 6c 6c 20 62 65 20 61 63 63 65 70 74 65 will be accepte
1420: 64 20 6f 6e 20 73 75 62 73 65 71 75 65 6e 74 20 d on subsequent
1430: 73 79 6e 63 0a 20 20 40 20 6f 70 65 72 61 74 69 sync. @ operati
1440: 6f 6e 73 2e 3c 2f 70 3e 0a 20 20 40 0a 20 20 40 ons.</p>. @. @
1450: 20 3c 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 <blockquote>.
1460: 40 20 3c 66 6f 72 6d 20 6d 65 74 68 6f 64 3d 22 @ <form method="
1470: 50 4f 53 54 22 20 61 63 74 69 6f 6e 3d 22 25 73 POST" action="%s
1480: 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 25 73 28 (g.zBaseURL)/%s(
1490: 67 2e 7a 50 61 74 68 29 22 3e 0a 20 20 6c 6f 67 g.zPath)">. log
14a0: 69 6e 5f 69 6e 73 65 72 74 5f 63 73 72 66 5f 73 in_insert_csrf_s
14b0: 65 63 72 65 74 28 29 3b 0a 20 20 40 20 3c 69 6e ecret();. @ <in
14c0: 70 75 74 20 74 79 70 65 3d 22 74 65 78 74 22 20 put type="text"
14d0: 6e 61 6d 65 3d 22 75 75 69 64 22 20 73 69 7a 65 name="uuid" size
14e0: 3d 22 35 30 22 3e 0a 20 20 40 20 3c 69 6e 70 75 ="50">. @ <inpu
14f0: 74 20 74 79 70 65 3d 22 73 75 62 6d 69 74 22 20 t type="submit"
1500: 6e 61 6d 65 3d 22 73 75 62 22 20 76 61 6c 75 65 name="sub" value
1510: 3d 22 41 63 63 65 70 74 22 3e 0a 20 20 40 20 3c ="Accept">. @ <
1520: 2f 66 6f 72 6d 3e 0a 20 20 40 20 3c 2f 62 6c 6f /form>. @ </blo
1530: 63 6b 71 75 6f 74 65 3e 0a 20 20 40 0a 20 20 40 ckquote>. @. @
1540: 20 3c 70 3e 50 72 65 73 73 20 74 68 65 20 62 75 <p>Press the bu
1550: 74 74 6f 6e 20 62 65 6c 6f 77 20 74 6f 20 72 65 tton below to re
1560: 62 75 69 6c 64 20 74 68 65 20 72 65 73 70 6f 73 build the respos
1570: 69 74 6f 72 79 2e 20 20 54 68 65 20 72 65 62 75 itory. The rebu
1580: 69 6c 64 0a 20 20 40 20 6d 61 79 20 74 61 6b 65 ild. @ may take
1590: 20 73 65 76 65 72 61 6c 20 73 65 63 6f 6e 64 73 several seconds
15a0: 2c 20 73 6f 20 62 65 20 70 61 74 69 65 6e 74 20 , so be patient
15b0: 61 66 74 65 72 20 70 72 65 73 73 69 6e 67 20 74 after pressing t
15c0: 68 65 20 62 75 74 74 6f 6e 2e 3c 2f 70 3e 0a 20 he button.</p>.
15d0: 20 40 0a 20 20 40 20 3c 62 6c 6f 63 6b 71 75 6f @. @ <blockquo
15e0: 74 65 3e 0a 20 20 40 20 3c 66 6f 72 6d 20 6d 65 te>. @ <form me
15f0: 74 68 6f 64 3d 22 50 4f 53 54 22 20 61 63 74 69 thod="POST" acti
1600: 6f 6e 3d 22 25 73 28 67 2e 7a 42 61 73 65 55 52 on="%s(g.zBaseUR
1610: 4c 29 2f 25 73 28 67 2e 7a 50 61 74 68 29 22 3e L)/%s(g.zPath)">
1620: 0a 20 20 6c 6f 67 69 6e 5f 69 6e 73 65 72 74 5f . login_insert_
1630: 63 73 72 66 5f 73 65 63 72 65 74 28 29 3b 0a 20 csrf_secret();.
1640: 20 40 20 3c 69 6e 70 75 74 20 74 79 70 65 3d 22 @ <input type="
1650: 73 75 62 6d 69 74 22 20 6e 61 6d 65 3d 22 72 65 submit" name="re
1660: 62 75 69 6c 64 22 20 76 61 6c 75 65 3d 22 52 65 build" value="Re
1670: 62 75 69 6c 64 22 3e 0a 20 20 40 20 3c 2f 66 6f build">. @ </fo
1680: 72 6d 3e 0a 20 20 40 20 3c 2f 62 6c 6f 63 6b 71 rm>. @ </blockq
1690: 75 6f 74 65 3e 0a 20 20 40 20 20 0a 20 20 73 74 uote>. @ . st
16a0: 79 6c 65 5f 66 6f 6f 74 65 72 28 29 3b 0a 7d 0a yle_footer();.}.
16b0: 0a 2f 2a 0a 2a 2a 20 52 65 6d 6f 76 65 20 66 72 ./*.** Remove fr
16c0: 6f 6d 20 74 68 65 20 42 4c 4f 42 20 74 61 62 6c om the BLOB tabl
16d0: 65 20 61 6c 6c 20 61 72 74 69 66 61 63 74 73 20 e all artifacts
16e0: 74 68 61 74 20 61 72 65 20 69 6e 20 74 68 65 20 that are in the
16f0: 53 48 55 4e 20 74 61 62 6c 65 2e 0a 2a 2f 0a 76 SHUN table..*/.v
1700: 6f 69 64 20 73 68 75 6e 5f 61 72 74 69 66 61 63 oid shun_artifac
1710: 74 73 28 76 6f 69 64 29 7b 0a 20 20 53 74 6d 74 ts(void){. Stmt
1720: 20 71 3b 0a 20 20 64 62 5f 6d 75 6c 74 69 5f 65 q;. db_multi_e
1730: 78 65 63 28 0a 20 20 20 20 20 22 43 52 45 41 54 xec(. "CREAT
1740: 45 20 54 45 4d 50 20 54 41 42 4c 45 20 74 6f 73 E TEMP TABLE tos
1750: 68 75 6e 28 72 69 64 20 49 4e 54 45 47 45 52 20 hun(rid INTEGER
1760: 50 52 49 4d 41 52 59 20 4b 45 59 29 3b 22 0a 20 PRIMARY KEY);".
1770: 20 20 20 20 22 49 4e 53 45 52 54 20 49 4e 54 4f "INSERT INTO
1780: 20 74 6f 73 68 75 6e 20 53 45 4c 45 43 54 20 72 toshun SELECT r
1790: 69 64 20 46 52 4f 4d 20 62 6c 6f 62 2c 20 73 68 id FROM blob, sh
17a0: 75 6e 20 57 48 45 52 45 20 62 6c 6f 62 2e 75 75 un WHERE blob.uu
17b0: 69 64 3d 73 68 75 6e 2e 75 75 69 64 3b 22 0a 20 id=shun.uuid;".
17c0: 20 29 3b 0a 20 20 64 62 5f 70 72 65 70 61 72 65 );. db_prepare
17d0: 28 26 71 2c 0a 20 20 20 20 20 22 53 45 4c 45 43 (&q,. "SELEC
17e0: 54 20 72 69 64 20 46 52 4f 4d 20 64 65 6c 74 61 T rid FROM delta
17f0: 20 57 48 45 52 45 20 73 72 63 69 64 20 49 4e 20 WHERE srcid IN
1800: 74 6f 73 68 75 6e 22 0a 20 20 29 3b 0a 20 20 77 toshun". );. w
1810: 68 69 6c 65 28 20 64 62 5f 73 74 65 70 28 26 71 hile( db_step(&q
1820: 29 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 20 29 7b )==SQLITE_ROW ){
1830: 0a 20 20 20 20 69 6e 74 20 73 72 63 69 64 20 3d . int srcid =
1840: 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28 26 db_column_int(&
1850: 71 2c 20 30 29 3b 0a 20 20 20 20 63 6f 6e 74 65 q, 0);. conte
1860: 6e 74 5f 75 6e 64 65 6c 74 61 28 73 72 63 69 64 nt_undelta(srcid
1870: 29 3b 0a 20 20 7d 0a 20 20 64 62 5f 66 69 6e 61 );. }. db_fina
1880: 6c 69 7a 65 28 26 71 29 3b 0a 20 20 64 62 5f 6d lize(&q);. db_m
1890: 75 6c 74 69 5f 65 78 65 63 28 0a 20 20 20 20 20 ulti_exec(.
18a0: 22 44 45 4c 45 54 45 20 46 52 4f 4d 20 64 65 6c "DELETE FROM del
18b0: 74 61 20 57 48 45 52 45 20 72 69 64 20 49 4e 20 ta WHERE rid IN
18c0: 74 6f 73 68 75 6e 3b 22 0a 20 20 20 20 20 22 44 toshun;". "D
18d0: 45 4c 45 54 45 20 46 52 4f 4d 20 62 6c 6f 62 20 ELETE FROM blob
18e0: 57 48 45 52 45 20 72 69 64 20 49 4e 20 74 6f 73 WHERE rid IN tos
18f0: 68 75 6e 3b 22 0a 20 20 20 20 20 22 44 52 4f 50 hun;". "DROP
1900: 20 54 41 42 4c 45 20 74 6f 73 68 75 6e 3b 22 0a TABLE toshun;".
1910: 20 20 29 3b 0a 7d 0a );.}.