Hex Artifact Content
Not logged in

Artifact 935c21e13e8b974e45c0090190ced4fb76befc48:

File src/shun.c part of check-in [a48474bc75] - Improvements to the shunning algorithm. Add the shun page and an opportunity to shun or unshun artifacts in the artifact viewer. by drh on 2008-05-29 01:58:15.

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 7a 55 75 69 64 20 29 7b  }.  if( zUuid ){
0620: 0a 20 20 20 20 6e 55 75 69 64 20 3d 20 73 74 72  .    nUuid = str
0630: 6c 65 6e 28 7a 55 75 69 64 29 3b 0a 20 20 20 20  len(zUuid);.    
0640: 69 66 28 20 6e 55 75 69 64 21 3d 34 30 20 7c 7c  if( nUuid!=40 ||
0650: 20 21 76 61 6c 69 64 61 74 65 31 36 28 7a 55 75   !validate16(zUu
0660: 69 64 2c 20 6e 55 75 69 64 29 20 29 7b 0a 20 20  id, nUuid) ){.  
0670: 20 20 20 20 7a 55 75 69 64 20 3d 20 30 3b 0a 20      zUuid = 0;. 
0680: 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20     }else{.      
0690: 6d 65 6d 63 70 79 28 7a 43 61 6e 6f 6e 69 63 61  memcpy(zCanonica
06a0: 6c 2c 20 7a 55 75 69 64 2c 20 55 55 49 44 5f 53  l, zUuid, UUID_S
06b0: 49 5a 45 2b 31 29 3b 0a 20 20 20 20 20 20 63 61  IZE+1);.      ca
06c0: 6e 6f 6e 69 63 61 6c 31 36 28 7a 43 61 6e 6f 6e  nonical16(zCanon
06d0: 69 63 61 6c 2c 20 55 55 49 44 5f 53 49 5a 45 29  ical, UUID_SIZE)
06e0: 3b 0a 20 20 20 20 20 20 7a 55 75 69 64 20 3d 20  ;.      zUuid = 
06f0: 7a 43 61 6e 6f 6e 69 63 61 6c 3b 0a 20 20 20 20  zCanonical;.    
0700: 7d 0a 20 20 7d 0a 20 20 73 74 79 6c 65 5f 68 65  }.  }.  style_he
0710: 61 64 65 72 28 22 53 68 75 6e 6e 65 64 20 41 72  ader("Shunned Ar
0720: 74 69 66 61 63 74 73 22 29 3b 0a 20 20 69 66 28  tifacts");.  if(
0730: 20 7a 55 75 69 64 20 26 26 20 50 28 22 73 75 62   zUuid && P("sub
0740: 22 29 20 29 7b 0a 20 20 20 20 64 62 5f 6d 75 6c  ") ){.    db_mul
0750: 74 69 5f 65 78 65 63 28 22 44 45 4c 45 54 45 20  ti_exec("DELETE 
0760: 46 52 4f 4d 20 73 68 75 6e 20 57 48 45 52 45 20  FROM shun WHERE 
0770: 75 75 69 64 3d 27 25 73 27 22 2c 20 7a 55 75 69  uuid='%s'", zUui
0780: 64 29 3b 0a 20 20 20 20 69 66 28 20 64 62 5f 65  d);.    if( db_e
0790: 78 69 73 74 73 28 22 53 45 4c 45 43 54 20 31 20  xists("SELECT 1 
07a0: 46 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45 20  FROM blob WHERE 
07b0: 75 75 69 64 3d 27 25 73 27 22 2c 20 7a 55 75 69  uuid='%s'", zUui
07c0: 64 29 20 29 7b 0a 20 20 20 20 20 20 40 20 3c 70  d) ){.      @ <p
07d0: 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 62 6c  ><font color="bl
07e0: 75 65 22 3e 41 72 74 69 66 61 63 74 20 0a 20 20  ue">Artifact .  
07f0: 20 20 20 20 40 20 3c 61 20 68 72 65 66 3d 22 25      @ <a href="%
0800: 73 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 72  s(g.zBaseURL)/ar
0810: 74 69 66 61 63 74 2f 25 73 28 7a 55 75 69 64 29  tifact/%s(zUuid)
0820: 22 3e 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 20  ">%s(zUuid)</a> 
0830: 69 73 20 6e 6f 0a 20 20 20 20 20 20 40 20 6c 6f  is no.      @ lo
0840: 6e 67 65 72 20 62 65 69 6e 67 20 73 68 75 6e 6e  nger being shunn
0850: 65 64 2e 3c 2f 66 6f 6e 74 3e 3c 2f 70 3e 0a 20  ed.</font></p>. 
0860: 20 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 20 20     }else{.      
0870: 40 20 3c 70 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72  @ <p><font color
0880: 3d 22 62 6c 75 65 22 3e 41 72 74 69 66 61 63 74  ="blue">Artifact
0890: 20 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 20 77   %s(zUuid)</a> w
08a0: 69 6c 6c 20 6e 6f 20 6c 6f 6e 67 65 72 0a 20 20  ill no longer.  
08b0: 20 20 20 20 40 20 62 65 20 73 68 75 6e 6e 65 64      @ be shunned
08c0: 2e 20 20 42 75 74 20 69 74 20 64 6f 65 73 20 6e  .  But it does n
08d0: 6f 74 20 65 78 69 73 74 20 69 6e 20 74 68 65 20  ot exist in the 
08e0: 72 65 70 6f 73 69 74 6f 72 79 2e 20 20 49 74 0a  repository.  It.
08f0: 20 20 20 20 20 20 40 20 6d 61 79 20 62 65 20 6e        @ may be n
0900: 65 63 65 73 73 61 72 79 20 74 6f 20 72 65 62 75  ecessary to rebu
0910: 69 6c 64 20 74 68 65 20 72 65 70 6f 73 69 74 6f  ild the reposito
0920: 72 79 20 75 73 69 6e 67 20 74 68 65 0a 20 20 20  ry using the.   
0930: 20 20 20 40 20 3c 62 3e 66 6f 73 73 69 6c 20 72     @ <b>fossil r
0940: 65 62 75 69 6c 64 3c 2f 62 3e 20 63 6f 6d 6d 61  ebuild</b> comma
0950: 6e 64 2d 6c 69 6e 65 20 62 65 66 6f 72 65 20 74  nd-line before t
0960: 68 65 20 61 72 74 69 66 61 63 74 20 63 6f 6e 74  he artifact cont
0970: 65 6e 74 0a 20 20 20 20 20 20 40 20 63 61 6e 20  ent.      @ can 
0980: 70 75 6c 6c 65 64 20 69 6e 20 66 72 6f 6d 20 6f  pulled in from o
0990: 74 68 65 72 20 72 65 73 70 6f 73 69 74 6f 72 69  ther respositori
09a0: 65 73 2e 3c 2f 66 6f 6e 74 3e 3c 2f 70 3e 0a 20  es.</font></p>. 
09b0: 20 20 20 7d 0a 20 20 7d 0a 20 20 69 66 28 20 7a     }.  }.  if( z
09c0: 55 75 69 64 20 26 26 20 50 28 22 61 64 64 22 29  Uuid && P("add")
09d0: 20 29 7b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69   ){.    db_multi
09e0: 5f 65 78 65 63 28 22 49 4e 53 45 52 54 20 4f 52  _exec("INSERT OR
09f0: 20 49 47 4e 4f 52 45 20 49 4e 54 4f 20 73 68 75   IGNORE INTO shu
0a00: 6e 20 56 41 4c 55 45 53 28 27 25 73 27 29 22 2c  n VALUES('%s')",
0a10: 20 7a 55 75 69 64 29 3b 0a 20 20 20 20 40 20 3c   zUuid);.    @ <
0a20: 70 3e 3c 66 6f 6e 74 20 63 6f 6c 6f 72 3d 22 62  p><font color="b
0a30: 6c 75 65 22 3e 41 72 74 69 66 61 63 74 0a 20 20  lue">Artifact.  
0a40: 20 20 40 20 3c 61 20 68 72 65 66 3d 22 25 73 28    @ <a href="%s(
0a50: 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 72 74 69  g.zBaseURL)/arti
0a60: 66 61 63 74 2f 25 73 28 7a 55 75 69 64 29 22 3e  fact/%s(zUuid)">
0a70: 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 20 68 61  %s(zUuid)</a> ha
0a80: 73 20 62 65 65 6e 0a 20 20 20 20 40 20 73 68 75  s been.    @ shu
0a90: 6e 6e 65 64 2e 20 20 49 74 20 77 69 6c 6c 20 6e  nned.  It will n
0aa0: 6f 20 6c 6f 6e 67 65 72 20 62 65 20 70 75 73 68  o longer be push
0ab0: 65 64 2e 0a 20 20 20 20 40 20 49 74 20 77 69 6c  ed..    @ It wil
0ac0: 6c 20 62 65 20 72 65 6d 6f 76 65 64 20 66 72 6f  l be removed fro
0ad0: 6d 20 74 68 65 20 72 65 70 6f 73 69 74 6f 72 79  m the repository
0ae0: 20 74 68 65 20 6e 65 78 74 20 74 69 6d 65 20 74   the next time t
0af0: 68 65 20 72 65 73 70 6f 73 69 74 6f 72 79 0a 20  he respository. 
0b00: 20 20 20 40 20 69 73 20 72 65 62 75 69 6c 74 20     @ is rebuilt 
0b10: 75 73 69 6e 67 20 74 68 65 20 3c 62 3e 66 6f 73  using the <b>fos
0b20: 73 69 6c 20 72 65 62 75 69 6c 64 3c 2f 62 3e 20  sil rebuild</b> 
0b30: 63 6f 6d 6d 61 6e 64 2d 6c 69 6e 65 3c 2f 66 6f  command-line</fo
0b40: 6e 74 3e 3c 2f 70 3e 0a 20 20 7d 0a 20 20 40 20  nt></p>.  }.  @ 
0b50: 3c 70 3e 54 68 65 20 61 72 74 69 66 61 63 74 73  <p>The artifacts
0b60: 20 6c 69 73 74 65 64 20 62 65 6c 6f 77 20 68 61   listed below ha
0b70: 76 65 20 62 65 65 6e 20 73 68 75 6e 6e 65 64 20  ve been shunned 
0b80: 62 79 20 74 68 69 73 20 72 65 70 6f 73 69 74 6f  by this reposito
0b90: 72 79 2e 0a 20 20 40 20 54 68 69 73 20 6d 65 61  ry..  @ This mea
0ba0: 6e 73 20 74 68 61 74 20 74 68 65 20 61 72 74 69  ns that the arti
0bb0: 66 61 63 74 73 20 77 69 6c 6c 20 6e 6f 74 20 62  facts will not b
0bc0: 65 20 74 72 61 6e 73 6d 69 74 74 65 64 20 6f 6e  e transmitted on
0bd0: 20 61 20 70 75 73 68 20 6e 6f 72 0a 20 20 40 20   a push nor.  @ 
0be0: 72 65 63 69 65 76 65 64 20 6f 6e 20 61 20 70 75  recieved on a pu
0bf0: 6c 6c 2e 20 20 54 68 65 73 65 20 61 72 74 69 66  ll.  These artif
0c00: 61 63 74 73 20 61 72 65 20 62 61 6e 6e 65 64 20  acts are banned 
0c10: 66 72 6f 6d 20 74 68 65 20 72 65 73 70 6f 73 69  from the resposi
0c20: 74 6f 72 79 2e 3c 2f 70 3e 0a 20 20 40 20 3c 62  tory.</p>.  @ <b
0c30: 6c 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 64 62 5f  lockquote>.  db_
0c40: 70 72 65 70 61 72 65 28 26 71 2c 20 0a 20 20 20  prepare(&q, .   
0c50: 20 20 22 53 45 4c 45 43 54 20 75 75 69 64 2c 20    "SELECT uuid, 
0c60: 45 58 49 53 54 53 28 53 45 4c 45 43 54 20 31 20  EXISTS(SELECT 1 
0c70: 46 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45 20  FROM blob WHERE 
0c80: 62 6c 6f 62 2e 75 75 69 64 3d 73 68 75 6e 2e 75  blob.uuid=shun.u
0c90: 75 69 64 29 22 0a 20 20 20 20 20 22 20 20 46 52  uid)".     "  FR
0ca0: 4f 4d 20 73 68 75 6e 20 4f 52 44 45 52 20 42 59  OM shun ORDER BY
0cb0: 20 75 75 69 64 22 29 3b 0a 20 20 77 68 69 6c 65   uuid");.  while
0cc0: 28 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53  ( db_step(&q)==S
0cd0: 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20  QLITE_ROW ){.   
0ce0: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 55 75   const char *zUu
0cf0: 69 64 20 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 74  id = db_column_t
0d00: 65 78 74 28 26 71 2c 20 30 29 3b 0a 20 20 20 20  ext(&q, 0);.    
0d10: 69 6e 74 20 73 74 69 6c 6c 45 78 69 73 74 73 20  int stillExists 
0d20: 3d 20 64 62 5f 63 6f 6c 75 6d 6e 5f 69 6e 74 28  = db_column_int(
0d30: 26 71 2c 20 31 29 3b 0a 20 20 20 20 63 6e 74 2b  &q, 1);.    cnt+
0d40: 2b 3b 0a 20 20 20 20 69 66 28 20 73 74 69 6c 6c  +;.    if( still
0d50: 45 78 69 73 74 73 20 29 7b 0a 20 20 20 20 20 20  Exists ){.      
0d60: 40 20 3c 62 3e 3c 61 20 68 72 65 66 3d 22 25 73  @ <b><a href="%s
0d70: 28 67 2e 7a 42 61 73 65 55 52 4c 29 2f 61 72 74  (g.zBaseURL)/art
0d80: 69 66 61 63 74 2f 25 73 28 7a 55 75 69 64 29 22  ifact/%s(zUuid)"
0d90: 3e 25 73 28 7a 55 75 69 64 29 3c 2f 61 3e 3c 2f  >%s(zUuid)</a></
0da0: 62 3e 3c 62 72 3e 0a 20 20 20 20 7d 65 6c 73 65  b><br>.    }else
0db0: 7b 0a 20 20 20 20 20 20 40 20 3c 62 3e 25 73 28  {.      @ <b>%s(
0dc0: 7a 55 75 69 64 29 3c 2f 62 3e 3c 62 72 3e 0a 20  zUuid)</b><br>. 
0dd0: 20 20 20 7d 0a 20 20 7d 0a 20 20 69 66 28 20 63     }.  }.  if( c
0de0: 6e 74 3d 3d 30 20 29 7b 0a 20 20 20 20 40 20 3c  nt==0 ){.    @ <
0df0: 69 3e 6e 6f 20 61 72 74 69 66 61 63 74 73 20 61  i>no artifacts a
0e00: 72 65 20 73 68 75 6e 6e 65 64 20 6f 6e 20 74 68  re shunned on th
0e10: 69 73 20 73 65 72 76 65 72 3c 2f 69 3e 0a 20 20  is server</i>.  
0e20: 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28  }.  db_finalize(
0e30: 26 71 29 3b 0a 20 20 40 20 3c 2f 62 6c 6f 63 6b  &q);.  @ </block
0e40: 71 75 6f 74 65 3e 0a 20 20 40 20 3c 68 72 3e 0a  quote>.  @ <hr>.
0e50: 20 20 40 20 3c 70 3e 54 6f 20 73 68 75 6e 20 61    @ <p>To shun a
0e60: 6e 20 61 72 74 69 66 61 63 74 2c 20 65 6e 74 65  n artifact, ente
0e70: 72 20 69 74 73 20 55 55 49 44 20 69 6e 20 74 68  r its UUID in th
0e80: 65 0a 20 20 40 20 66 6f 6c 6c 6f 77 69 6e 67 20  e.  @ following 
0e90: 62 6f 78 20 61 6e 64 20 70 72 65 73 73 20 74 68  box and press th
0ea0: 65 20 22 53 68 75 6e 22 20 62 75 74 74 6f 6e 2e  e "Shun" button.
0eb0: 20 20 54 68 69 73 20 77 69 6c 6c 20 63 61 75 73    This will caus
0ec0: 65 20 74 68 65 20 61 72 74 69 66 61 63 74 0a 20  e the artifact. 
0ed0: 20 40 20 74 6f 20 62 65 20 72 65 6d 6f 76 65 64   @ to be removed
0ee0: 20 66 72 6f 6d 20 74 68 65 20 72 65 70 6f 73 69   from the reposi
0ef0: 74 6f 72 79 20 61 6e 64 20 77 69 6c 6c 20 70 72  tory and will pr
0f00: 65 76 65 6e 74 20 74 68 65 20 61 72 74 69 66 61  event the artifa
0f10: 63 74 20 66 72 6f 6d 20 62 65 69 6e 67 0a 20 20  ct from being.  
0f20: 40 20 72 65 61 64 64 65 64 20 74 6f 20 74 68 65  @ readded to the
0f30: 20 72 65 70 6f 73 69 74 6f 72 79 20 62 79 20 73   repository by s
0f40: 75 62 73 65 71 75 65 6e 74 20 73 79 6e 63 20 6f  ubsequent sync o
0f50: 70 65 72 61 74 69 6f 6e 2e 3c 2f 70 3e 0a 20 20  peration.</p>.  
0f60: 40 0a 20 20 40 20 3c 70 3e 57 61 72 6e 69 6e 67  @.  @ <p>Warning
0f70: 3a 20 20 53 68 75 6e 6e 69 6e 67 20 73 68 6f 75  :  Shunning shou
0f80: 6c 64 20 6f 6e 6c 79 20 62 65 20 75 73 65 64 20  ld only be used 
0f90: 74 6f 20 72 65 6d 6f 76 65 20 69 6e 61 70 70 72  to remove inappr
0fa0: 6f 70 72 69 61 74 65 20 63 6f 6e 74 65 6e 74 0a  opriate content.
0fb0: 20 20 40 20 66 72 6f 6d 20 74 68 65 20 72 65 70    @ from the rep
0fc0: 6f 73 69 74 6f 72 79 2e 20 20 49 6e 61 70 70 72  ository.  Inappr
0fd0: 6f 70 72 69 61 74 65 20 63 6f 6e 74 65 6e 74 20  opriate content 
0fe0: 69 6e 63 6c 75 64 65 73 20 73 75 63 68 20 74 68  includes such th
0ff0: 69 6e 67 73 20 61 73 0a 20 20 40 20 73 70 61 6d  ings as.  @ spam
1000: 20 61 64 64 65 64 20 74 6f 20 57 69 6b 69 2c 20   added to Wiki, 
1010: 66 69 6c 65 73 20 74 68 61 74 20 76 69 6f 6c 61  files that viola
1020: 74 65 20 63 6f 70 79 72 69 67 68 74 20 6f 72 20  te copyright or 
1030: 70 61 74 65 6e 74 20 61 67 72 65 65 6d 65 6e 74  patent agreement
1040: 73 2c 0a 20 20 40 20 6f 72 20 61 72 74 69 66 61  s,.  @ or artifa
1050: 63 74 73 20 74 68 61 74 20 62 79 20 64 65 73 69  cts that by desi
1060: 67 6e 20 6f 72 20 61 63 63 69 64 65 6e 74 20 69  gn or accident i
1070: 6e 74 65 72 66 65 72 65 20 77 69 74 68 20 74 68  nterfere with th
1080: 65 20 70 72 6f 63 65 73 73 69 6e 67 0a 20 20 40  e processing.  @
1090: 20 6f 66 20 74 68 65 20 72 65 70 6f 73 69 74 6f   of the reposito
10a0: 72 79 2e 20 20 44 6f 20 6e 6f 74 20 73 68 75 6e  ry.  Do not shun
10b0: 20 61 72 74 69 66 61 63 74 73 20 6d 65 72 65 6c   artifacts merel
10c0: 79 20 74 6f 20 72 65 6d 6f 76 65 20 74 68 65 6d  y to remove them
10d0: 20 66 72 6f 6d 0a 20 20 40 20 73 69 67 68 74 20   from.  @ sight 
10e0: 2d 20 73 65 74 20 74 68 65 20 22 68 69 64 64 65  - set the "hidde
10f0: 6e 22 20 74 61 67 20 6f 6e 20 73 75 63 68 20 61  n" tag on such a
1100: 72 74 69 66 61 63 74 73 20 69 6e 73 74 65 61 64  rtifacts instead
1110: 2e 3c 2f 70 3e 0a 20 20 40 20 0a 20 20 40 20 3c  .</p>.  @ .  @ <
1120: 62 6c 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 40 20  blockquote>.  @ 
1130: 3c 66 6f 72 6d 20 6d 65 74 68 6f 64 3d 22 50 4f  <form method="PO
1140: 53 54 22 20 61 63 74 69 6f 6e 3d 22 25 73 28 67  ST" action="%s(g
1150: 2e 7a 42 61 73 65 55 52 4c 29 2f 25 73 28 67 2e  .zBaseURL)/%s(g.
1160: 7a 50 61 74 68 29 22 3e 0a 20 20 40 20 3c 69 6e  zPath)">.  @ <in
1170: 70 75 74 20 74 79 70 65 3d 22 74 65 78 74 22 20  put type="text" 
1180: 6e 61 6d 65 3d 22 75 75 69 64 22 20 73 69 7a 65  name="uuid" size
1190: 3d 22 35 30 22 3e 0a 20 20 40 20 3c 69 6e 70 75  ="50">.  @ <inpu
11a0: 74 20 74 79 70 65 3d 22 73 75 62 6d 69 74 22 20  t type="submit" 
11b0: 6e 61 6d 65 3d 22 61 64 64 22 20 76 61 6c 75 65  name="add" value
11c0: 3d 22 53 68 75 6e 22 3e 0a 20 20 40 20 3c 2f 66  ="Shun">.  @ </f
11d0: 6f 72 6d 3e 0a 20 20 40 20 3c 2f 62 6c 6f 63 6b  orm>.  @ </block
11e0: 71 75 6f 74 65 3e 0a 20 20 40 0a 20 20 40 20 3c  quote>.  @.  @ <
11f0: 70 3e 45 6e 74 65 72 20 74 68 65 20 55 55 49 44  p>Enter the UUID
1200: 20 6f 66 20 61 20 70 72 65 76 69 6f 75 73 20 73   of a previous s
1210: 68 75 6e 6e 65 64 20 61 72 74 69 66 61 63 74 20  hunned artifact 
1220: 74 6f 20 63 61 75 73 65 20 69 74 20 74 6f 20 62  to cause it to b
1230: 65 0a 20 20 40 20 61 63 63 65 70 74 65 64 20 61  e.  @ accepted a
1240: 67 61 69 6e 20 69 6e 20 74 68 65 20 72 65 70 6f  gain in the repo
1250: 73 69 74 6f 72 79 2e 20 20 54 68 65 20 61 72 74  sitory.  The art
1260: 69 66 61 63 74 20 63 6f 6e 74 65 6e 74 20 69 73  ifact content is
1270: 20 6e 6f 74 0a 20 20 40 20 72 65 73 74 6f 72 65   not.  @ restore
1280: 64 20 62 65 63 61 75 73 65 20 74 68 65 20 63 6f  d because the co
1290: 6e 74 65 6e 74 20 69 73 20 75 6e 6b 6e 6f 77 6e  ntent is unknown
12a0: 2e 20 20 54 68 65 20 6f 6e 6c 79 20 63 68 61 6e  .  The only chan
12b0: 67 65 20 69 73 20 74 68 61 74 0a 20 20 40 20 74  ge is that.  @ t
12c0: 68 65 20 66 6f 72 6d 65 72 6c 79 20 73 68 75 6e  he formerly shun
12d0: 6e 65 64 20 61 72 74 69 66 61 63 74 20 77 69 6c  ned artifact wil
12e0: 6c 20 62 65 20 61 63 63 65 70 74 65 64 20 6f 6e  l be accepted on
12f0: 20 73 75 62 73 65 71 75 65 6e 74 20 73 79 6e 63   subsequent sync
1300: 0a 20 20 40 20 6f 70 65 72 61 74 69 6f 6e 73 2e  .  @ operations.
1310: 3c 2f 70 3e 0a 20 20 40 0a 20 20 40 20 3c 62 6c  </p>.  @.  @ <bl
1320: 6f 63 6b 71 75 6f 74 65 3e 0a 20 20 40 20 3c 66  ockquote>.  @ <f
1330: 6f 72 6d 20 6d 65 74 68 6f 64 3d 22 50 4f 53 54  orm method="POST
1340: 22 20 61 63 74 69 6f 6e 3d 22 25 73 28 67 2e 7a  " action="%s(g.z
1350: 42 61 73 65 55 52 4c 29 2f 25 73 28 67 2e 7a 50  BaseURL)/%s(g.zP
1360: 61 74 68 29 22 3e 0a 20 20 40 20 3c 69 6e 70 75  ath)">.  @ <inpu
1370: 74 20 74 79 70 65 3d 22 74 65 78 74 22 20 6e 61  t type="text" na
1380: 6d 65 3d 22 75 75 69 64 22 20 73 69 7a 65 3d 22  me="uuid" size="
1390: 35 30 22 3e 0a 20 20 40 20 3c 69 6e 70 75 74 20  50">.  @ <input 
13a0: 74 79 70 65 3d 22 73 75 62 6d 69 74 22 20 6e 61  type="submit" na
13b0: 6d 65 3d 22 73 75 62 22 20 76 61 6c 75 65 3d 22  me="sub" value="
13c0: 41 63 63 65 70 74 22 3e 0a 20 20 40 20 3c 2f 66  Accept">.  @ </f
13d0: 6f 72 6d 3e 0a 20 20 40 20 3c 2f 62 6c 6f 63 6b  orm>.  @ </block
13e0: 71 75 6f 74 65 3e 0a 20 20 73 74 79 6c 65 5f 66  quote>.  style_f
13f0: 6f 6f 74 65 72 28 29 3b 0a 7d 0a 0a 2f 2a 0a 2a  ooter();.}../*.*
1400: 2a 20 52 65 6d 6f 76 65 20 66 72 6f 6d 20 74 68  * Remove from th
1410: 65 20 42 4c 4f 42 20 74 61 62 6c 65 20 61 6c 6c  e BLOB table all
1420: 20 61 72 74 69 66 61 63 74 73 20 74 68 61 74 20   artifacts that 
1430: 61 72 65 20 69 6e 20 74 68 65 20 53 48 55 4e 20  are in the SHUN 
1440: 74 61 62 6c 65 2e 0a 2a 2f 0a 76 6f 69 64 20 73  table..*/.void s
1450: 68 75 6e 5f 61 72 74 69 66 61 63 74 73 28 76 6f  hun_artifacts(vo
1460: 69 64 29 7b 0a 20 20 53 74 6d 74 20 71 3b 0a 20  id){.  Stmt q;. 
1470: 20 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 0a   db_multi_exec(.
1480: 20 20 20 20 20 22 43 52 45 41 54 45 20 54 45 4d       "CREATE TEM
1490: 50 20 54 41 42 4c 45 20 74 6f 73 68 75 6e 28 72  P TABLE toshun(r
14a0: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  id INTEGER PRIMA
14b0: 52 59 20 4b 45 59 29 3b 22 0a 20 20 20 20 20 22  RY KEY);".     "
14c0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 6f 73 68  INSERT INTO tosh
14d0: 75 6e 20 53 45 4c 45 43 54 20 72 69 64 20 46 52  un SELECT rid FR
14e0: 4f 4d 20 62 6c 6f 62 2c 20 73 68 75 6e 20 57 48  OM blob, shun WH
14f0: 45 52 45 20 62 6c 6f 62 2e 75 75 69 64 3d 73 68  ERE blob.uuid=sh
1500: 75 6e 2e 75 75 69 64 3b 22 0a 20 20 29 3b 0a 20  un.uuid;".  );. 
1510: 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c 0a   db_prepare(&q,.
1520: 20 20 20 20 20 22 53 45 4c 45 43 54 20 72 69 64       "SELECT rid
1530: 20 46 52 4f 4d 20 64 65 6c 74 61 20 57 48 45 52   FROM delta WHER
1540: 45 20 73 72 63 69 64 20 49 4e 20 74 6f 73 68 75  E srcid IN toshu
1550: 6e 22 0a 20 20 29 3b 0a 20 20 77 68 69 6c 65 28  n".  );.  while(
1560: 20 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51   db_step(&q)==SQ
1570: 4c 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20  LITE_ROW ){.    
1580: 69 6e 74 20 73 72 63 69 64 20 3d 20 64 62 5f 63  int srcid = db_c
1590: 6f 6c 75 6d 6e 5f 69 6e 74 28 26 71 2c 20 30 29  olumn_int(&q, 0)
15a0: 3b 0a 20 20 20 20 63 6f 6e 74 65 6e 74 5f 75 6e  ;.    content_un
15b0: 64 65 6c 74 61 28 73 72 63 69 64 29 3b 0a 20 20  delta(srcid);.  
15c0: 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28  }.  db_finalize(
15d0: 26 71 29 3b 0a 20 20 64 62 5f 6d 75 6c 74 69 5f  &q);.  db_multi_
15e0: 65 78 65 63 28 0a 20 20 20 20 20 22 44 45 4c 45  exec(.     "DELE
15f0: 54 45 20 46 52 4f 4d 20 64 65 6c 74 61 20 57 48  TE FROM delta WH
1600: 45 52 45 20 72 69 64 20 49 4e 20 74 6f 73 68 75  ERE rid IN toshu
1610: 6e 3b 22 0a 20 20 20 20 20 22 44 45 4c 45 54 45  n;".     "DELETE
1620: 20 46 52 4f 4d 20 62 6c 6f 62 20 57 48 45 52 45   FROM blob WHERE
1630: 20 72 69 64 20 49 4e 20 74 6f 73 68 75 6e 3b 22   rid IN toshun;"
1640: 0a 20 20 20 20 20 22 44 52 4f 50 20 54 41 42 4c  .     "DROP TABL
1650: 45 20 74 6f 73 68 75 6e 3b 22 0a 20 20 29 3b 0a  E toshun;".  );.
1660: 7d 0a                                            }.