summaryrefslogtreecommitdiff
path: root/gentoobrowse/console/fileimport.xml
blob: 5d326e962dd45a71085bcd5bf2bea1ad9a633d9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?xml version="1.0"?>
<packageimport name="bugassociate" xmlns:xi="http://www.w3.org/2001/XInclude"
		xmlns:project2="http://project2.randomdan.homeip.net">
	<xi:include href="../datasources/postgres.xml" />
	<project2:sqlmerge name="files" datasource="postgres" targettable="files">
		<project2:sqliterate name="filetypes" datasource="postgres">
			<sql>
				SELECT filetypeid, searchroot, LENGTH(searchroot) + 1 || '-' AS rootlen, searchspec
				FROM filetypes
				ORDER BY filetypeid DESC
			</sql>
			<project2:prociterate name="findCacheFiles" newline="&#10;" encoding="ascii" fieldSep="|" quoteChar=""
					path="*find ^searchroot ^searchspec -printf &quot;%p|%t\n&quot; | cut -b ^rootlen | sed &apos;s#^# ^filetypeid |#&apos;" >
				<columns>
					<column>filetypeid</column>
					<column>filename</column>
					<column>moddate</column>
				</columns>
			</project2:prociterate>
		</project2:sqliterate>
		<columns>
			<column key="true">filename</column>
			<column>moddate</column>
			<column>filetypeid</column>
		</columns>
	</project2:sqlmerge>

	<project2:sqlmerge name="loadCacheContent" datasource="postgres" targettable="filecache"
			updatewhere="*a.fileid IN (SELECT o.fileid FROM files o WHERE o.cachedat IS NULL OR o.cachedat != o.moddate)">
		<project2:sqliterate name="outDatadFiles" datasource="postgres">
			<sql>
				SELECT f.fileid, ft.searchroot || f.filename AS filename, f.cachedat, f.moddate
				FROM files f, filetypes ft
				WHERE (f.cachedat IS NULL OR f.cachedat != f.moddate)
				AND f.filetypeid = ft.filetypeid
				ORDER BY f.fileid;
			</sql>
			<project2:prociterate name="readFileContent" newline="&#10;" encoding="utf-8" fieldSep="|" quoteChar=""
					path="*grep -n . ^filename | sed -e &apos;s#:#|#&apos; -e &apos;s#^# ^fileid |#&apos;" >
				<columns>
					<column>fileid</column>
					<column>line</column>
					<column>content</column>
				</columns>
			</project2:prociterate>
		</project2:sqliterate>
		<columns>
			<column key="true">fileid</column>
			<column key="true">line</column>
			<column>content</column>
		</columns>
	</project2:sqlmerge>
	<project2:sqltask name="setCachedTime" datasource="postgres">
		<sql>UPDATE files SET cachedat = moddate WHERE cachedat != moddate OR cachedat IS NULL</sql>
	</project2:sqltask>
</packageimport>