Index: other-projects/nightly-tasks/crons-and-scripts/do-snapshots-and-latest.sh
===================================================================
--- other-projects/nightly-tasks/crons-and-scripts/do-snapshots-and-latest.sh	(revision 29998)
+++ other-projects/nightly-tasks/crons-and-scripts/do-snapshots-and-latest.sh	(revision 30002)
@@ -18,7 +18,13 @@
 gs3version=`cat /greenstone/greenstone.org/base/next-release-greenstone3.txt`
 
+# array of string literals of source component/distribution suffixes
+
+source_suffixes=("source-component.tar.gz" "source-component.zip" "source-distribution.tar.gz" "source-distribution.zip")
+
 # static array of string literals representing the caveat file suffixes we're interested in
-
-suffixes=("linux" "linux-x64" "Lion-MacOS-intel.dmg" "MacOS-intel.dmg" "windows.exe" "source-component.tar.gz" "source-component.zip" "source-distribution.tar.gz" "source-distribution.zip")
+# see also 'Adding New Elements to the Original Array' 
+# at http://www.yourownlinux.com/2013/10/working-with-arrays-in-bash-scripting.html
+
+suffixes=("linux" "linux-x64" "Lion-MacOS-intel.dmg" "MacOS-intel.dmg" "windows.exe" ${source_suffixes[@]})
 
 gs2_bin_prefix=Greenstone-$gs2version-candidate-$today-
@@ -184,5 +190,5 @@
     cd $caveat_dir
     for file in *; do
-	[[ -f $file ]] && [[ "$file" != *"latest-server.exe" ]] && [[ "$file" != *"Greenstone3-latest-source.tar.gz" ]] && [[ $file -nt $latest ]] && latest=$file
+	[[ -f $file ]] && [[ "$file" == "Greenstone-"* ]] && [[ "$file" != *"Greenstone3-latest-source.tar.gz" ]] && [[ $file -nt $latest ]] && latest=$file
     done
     cd -
@@ -192,4 +198,10 @@
     # E.g. for testing, latest=Greenstone-3.07-candidate-2015.06.30-linux-x64
     echo "Latest file in caveat is: $latest"
+
+    # splits the filename $latest by hyphens, -, and then gets the 2nd substring
+    # in this case the GS2 or GS3 full version number
+    # http://stackoverflow.com/questions/428109/extract-substring-in-bash
+    local matchfile=`echo $latest| cut -d'-' -f 2`
+    echo "Found gs version prefix: $matchfile"
 
     # Iff this is a GS binary/src file that we want to maintain in the caveat/latest folder,
@@ -203,30 +215,47 @@
     # Need double brackets below, [[]], for string expansion with wildcard
 
-    for suffix in ${suffixes[@]}; do
-	if [[ "$latest" == *"$suffix" ]]; then
-	    echo "Found that suffix matched: $suffix"
-
-	    # splits the filename $latest by hyphens, -, and then gets the 2nd substring
-	    # in this case the GS2 or GS3 full version number
-	    # http://stackoverflow.com/questions/428109/extract-substring-in-bash
-	    local matchfile=`echo $latest| cut -d'-' -f 2`
-	    echo "Found gs version prefix: $matchfile"
-
-	    matchfile=${latest_dir}Greenstone-${matchfile}-candidate-*-${suffix}
-
+
+    # if the latest file is a src component or src dist, then all src comps and dists
+    # would have been uploaded simultaneously for that GS version. Check they're all there
+    # and remove any older equivalents in the caveat/latest directory. Then copy all the 
+    # *source* files for this GS version over to caveat/latest
+
+    echo ""
+    if [[ "$latest" == *"-source-"* ]]; then
+	for suffix in ${source_suffixes[@]}; do
+	    local srcfile=Greenstone-${matchfile}-candidate-${today}-${suffix}
+	    local regexfile=Greenstone-${matchfile}-candidate-*-${suffix}
+	    if [[ -f ${caveat_dir}$srcfile ]]; then
+		echo "Removing ${latest_dir}$regexfile"
+		echo "and replacing with ${latest_dir}$srcfile"
+		rm ${latest_dir}$regexfile
+		ln ${caveat_dir}$srcfile ${latest_dir}$srcfile
+	    fi
+	done
+    
+    else
+	# not src component or dist, but binary file, which are uploaded one at a time.
+
+	for suffix in ${suffixes[@]}; do
+	    if [[ "$latest" == *"$suffix" ]]; then
+		echo "Found that suffix matched: $suffix"
+		
+		matchfile=${latest_dir}Greenstone-${matchfile}-candidate-*-${suffix}
+		
        	    # remove the matching file from the caveat/latest folder
 	    # we don't know it's date, so we substituted that portion with a * as wildcard
 	    # E.g. matchfile=<caveat>/latest/Greenstone-2.87-candidate-*-source-component.tar.gz
-
-	    echo "Removing $matchfile"
-	    rm $matchfile
-
+		
+		echo "Removing $matchfile"
+		rm $matchfile
+		
 	    # make a hardlink of the $latest file into the caveat_latest folder
-	    echo "Making a hardlink to ${caveat_dir}$latest in ${latest_dir}$latest"
-	    ln ${caveat_dir}$latest ${latest_dir}$latest
-	#else
-	    #echo "$latest did not match $suffix"
-	fi
-    done
+		echo "Making a hardlink to ${caveat_dir}$latest in ${latest_dir}$latest"
+		ln ${caveat_dir}$latest ${latest_dir}$latest
+	    #else
+		#echo "$latest did not match $suffix"
+	    fi
+	done
+    fi
 
     echo ""
