 <!---------------------------------------------------------------------------------------------------------->
 <cfif action is "cleanup_local">
 	<cfquery name="d" datasource="cf_dbuser">
-		 select * from cf_tacc_transfer where status='media_updated' and rownum<1000
+		 select LOCAL_URI,REMOTE_URI from cf_tacc_transfer where status='media_updated' and rownum<1000
 	</cfquery>
 	<cfoutput>
 		<cfloop query="d">
+
 			<cfset localfPath=replace(LOCAL_URI,#application.serverRootUrl#,'#application.webDirectory#')>
+
 			<cfif fileExists(localfPath)>
-
-				this thing exists:
+				<br>this thing exists:
 				<br>localfPath: #localfPath#
 				<br>LOCAL_URI: #LOCAL_URI#
 				<br>REMOTE_URI: #REMOTE_URI#

				<cfdirectory action="delete" directory="#directory#/#name#">
			</cfif>


		</cfif>
	</cfloop>

	<cfdirectory action="LIST"
    	directory="#Application.webDirectory#/mediaUploads"
        name="root"
		recurse="yes">
	<cfloop query="root">
		<cfif type is "file">
			<br>found #directory#/#name#
			<cfset webpath=replace(directory,application.webDirectory,application.serverRootUrl) & "/" & name>
			<br>webpath: #webpath#
			<cfquery name="isUsed" datasource="uam_god">
				select media_id from media where
					(
						media_uri='#webpath#' or
						preview_uri='#webpath#'
					)
			</cfquery>
			<br>isUsed.recordcount: #isUsed.recordcount#
			<cfif isUsed.recordcount is 0>
				<br>going to delete
				<cfif (dateCompare(dateAdd("d",7,datelastmodified),now()) LTE 0) and left(name,1) neq ".">
				 	<cffile action="delete" file="#directory#/#name#">
				 </cfif>
			</cfif>
		<cfelse>
			<cfdirectory action="list" directory="#directory#/#name#" name="current">
			<br> got a directory #directory#/#name# containing #current.recordcount# files
			<cfif current.recordcount is 0>
				<br>deleting it
				<cfif (dateCompare(dateAdd("d",7,datelastmodified),now()) LTE 0) and left(name,1) neq ".">
				 	<cffile action="delete" file="#directory#/#name#">
				 </cfif>
			</cfif>
		</cfif>
	</cfloop>
</cfoutput>
</cfif>

<!---------------------------------------------------------------------------------------------------------->
<cfif action is "downloadLocalPath">


<br><a href="localToTacc.cfm?action=checkchecksum">checkchecksum</a> - do this third, it checks that everything is happy

<br><a href="localToTacc.cfm?action=cleanup_local">cleanup_local</a> - mark files where the local is confirmed delete
	(and these can be deleted from the temp table; they're all done)


<br><a href="localToTacc.cfm?action=showstatus">showstatus</a> - wut?
