32cd2100d9dd11140705c848850e86c4f79191c4
max
Tue Sep 1 07:02:04 2026 -0700
Reusable "view snapshot" sessions for durable, minimal Share-a-link links
"Share a link" could only share the whole cart: it saved a session holding
every track, setting and position, which bloated the central db and leaked
the sharer's unrelated tracks to whoever opened the link. Anonymous share
sessions (under the reserved user "l") were also never reaped, so they
accumulated forever, and their 8-char names were generated client-side with
no uniqueness check, so two shares could collide and silently overwrite.
Adds a lightweight "snapshot session" facility (lib/snapshotSession.c): a
snapshot stores only the handful of cart variables a feature declares (a
registered snapshotType, e.g. "blat" -> {db, blatLastBigBed}), moves only
those variables' trash files into durable sessionData storage, and is saved
under a "__"-prefixed name. The "__" marks it machine-made: hidden from the
My Sessions list by default and eligible for reaping. For the anonymous "l"
owner the durable files fan out over two extra hash levels so one directory
never fills with millions of entries.
Every anonymous link now shares one server-side name generator
(snapshotNewName): a unique (db-checked), crypto-strong, "__"-prefixed token,
so tokens never collide. The hgSession doSaveSessionJson endpoint gained
hgS_snapshotType (save a minimal snapshot rather than the whole cart) and
hgS_doAnonName (reserve a unique anonymous name without saving, so the
top-right dialog can preview the exact link before it is created).
Wired three callers to the facility:
- hgc htcBlatAlign "Share a link": a minimal "blat" snapshot instead of a
full-cart anonymous session.
- hgBlat results "Share a link": creates a "blat" snapshot on click and
reveals its ?u=&s= reopen link (rebuilt from the durable bigPsl by the
existing doShareReopen), replacing the trash-only reveal.
- top-right "Share a link": anonymous links use the reserved server name;
logged-in named shares are unchanged.
snapshotReaper (hg/utils) garbage-collects abandoned anonymous snapshots: it
deletes user "l" "__" rows whose lastUse is older than the TTL (hg.conf
snapshot.ttlDays, default ~4 years) and removes their durable files. lastUse
is bumped on every open by the existing session load, so a link stays alive
as long as it is used. Meant to run from the trash-cleaner cron.
Also folds in the recent Share-dialog work in these files: the auto share
name is a short "_" prefix instead of "share_", the dialog previews the link
and creates it only when the button is clicked (no orphan session just from
opening the dialog), an optional name field with an overwrite warning, and
the anonymous save path forces the reap-eligible "__" name.
refs #38197
diff --git src/hg/utils/makefile src/hg/utils/makefile
index 8c1951dac1f..82a4043b83f 100644
--- src/hg/utils/makefile
+++ src/hg/utils/makefile
@@ -1,163 +1,164 @@
# Build all directories in utils
# test comment
# $Id: makefile,v 1.21 2010/06/04 00:12:42 larrym Exp $
kentSrc = ../..
include ${kentSrc}/inc/localEnvironment.mk
include ${kentSrc}/inc/common.mk
# to check for Mac OSX Darwin specifics:
UNAME_S := $(shell uname -s)
# can not build this on Mac OSX - has functions not supported
ifeq ($(UNAME_S),Darwin)
buildRefresh=
else
buildRefresh=refreshNamedSessionCustomTracks
endif
# List of directories to build for userApps
UTILS_APPLIST = \
bedExtendRanges \
bedToPsl \
bedWeedOverlapping \
bedMergeAdjacent \
bedPartition \
bigChainBreaks \
bigChainToChain \
bigGenePredToGenePred \
bigMafToMaf \
bigPslToPsl \
binFromRange \
chainToBigChain \
chromGraphFromBin \
chromGraphToBin \
crTreeIndexBed \
crTreeSearchBed \
faToVcf \
gapToLift \
genePredFilter \
genePredToBigGenePred \
genePredToProt \
gencodeVersionForGenes \
gff3ToGenePred \
gff3ToPsl \
gtfToGenePred \
hicInfo \
hgvsToVcf \
hubCheck \
hubClone \
hubPublicCheck \
mafToBigMaf \
mafToBigMafSummary \
makeTableList \
oligoMatch \
overlapSelect \
positionalTblCheck \
pslLiftSubrangeBlat \
pslToBigPsl \
raSqlQuery \
rmskAlignToPsl \
tdbQuery \
transMapPslToGenePred \
twoBitMask \
vcfToBed \
fixTrackDb
USER_APP_SCRIPTS = \
vai.pl
SCRIPT_FILES = \
archiveTracks.sh \
dbNsfpToBed.pl \
dumpDb.pl \
mergeOverlapBed4.pl \
mergeSortedBed3Plus.pl \
mysqlRowSizes.pl \
${USER_APP_SCRIPTS}
APP_SCRIPTS = ${SCRIPT_FILES}
# List of directories to build of interest only at UCSC
DIRS = ${buildRefresh} \
automation \
rts \
blatServersCheck \
buildReleaseLog \
checkUrlsInTable \
geoMirrorNode \
hubCrawl \
makeTrackIndex \
mysqlSecurityCheck \
phyloRenameAndPrune \
pslFixCdsJoinGap \
pslMismatchGapToBed \
pslUniq \
refSeqGet \
safePush \
scaffoldFaToAgp \
+ snapshotReaper \
toDev64 \
vcfRenameAndPrune \
vcfToHgvs \
wigBedToStep
TEST_DIRS = \
bedMergeAdjacent \
bedPartition \
genePredFilter \
genePredToProt \
gff3ToGenePred \
gff3ToPsl \
gtfToGenePred \
hgvsToVcf \
hubCheck \
mafToBigMafSummary \
overlapSelect \
pslToBigPsl \
refSeqGet \
transMapPslToGenePred \
vcfToHgvs
APPS = $(DIRS) $(UTILS_APPLIST)
all:: utils
utils: $(APPS:%=%.utils) $(APP_SCRIPTS:%=%.appScript)
# tolerate missing directories, as some were removed in kent-core
%.utils:
if test -d $* ; then cd $* && echo $* && $(MAKE) ; fi
%.appScript:
chmod +x $*
rm -f ${DESTDIR}${SCRIPTS}/$*
cp -p $* ${DESTDIR}${SCRIPTS}/$*
userApps: $(UTILS_APPLIST:%=%.userApp) $(USER_APP_SCRIPTS:%=%.userAppScript)
%.userApp:
if test -d $* ; then cd $* && echo $* && $(MAKE) ; fi
%.userAppScript:
chmod +x $*
rm -f ${DESTDIR}${BINDIR}/$*
cp -p $* ${DESTDIR}${BINDIR}/$*
scripts: $(SCRIPT_FILES:%=%.scripts)
%.scripts:
chmod +x $*
rm -f ${SCRIPTS}/$*
cp -p $* ${SCRIPTS}/$*
alpha: scripts all
test:: ${TEST_DIRS:%=%.test}
%.test:
(cd $* && ${MAKE} test)
clean:: $(APPS:%=%.clean)
- find . -name '*.o' -exec rm {} \;
%.clean:
(if test -d $* ; then cd $* && echo $* && $(MAKE) clean; fi)
compile:: $(APPS:%=%.compile)
- find . -name '*.o' -exec rm {} \;
%.compile:
(cd $* && ${MAKE} compile)