;+
; Contains the upsert_files procedure
;
; :Author:
; Henri Chain
;
; :History:
; 31/03/15: Created
;-
;
;+
; Insert or update file info in the Kronos Database.
; Uses the pgsql_query DLM module (native IDL-Postgre communication).
;
; :Uses:
; pgsql_query
;
; :Params:
; files: in, required, type=sometype
; Filename or array of filenames to insert/update
;
; :Keywords:
; verbose: in, optional, type=boolean
; Show more debug info
;-
pro upsert_files, files, verbose = verbose
for i = 0L, n_elements(files) - 1 do begin
timestamp = -946684800000000LL + 1000000LL * (file_info(files[i])).mtime
query = "select upsert_file('" + files[i] + $
"', timestamp 'epoch' + interval '" + $
string((file_info(files[i])).mtime, format='(I0)') + " seconds')"
if (keyword_set(verbose)) then print, query
result = pgsql_query(query)
endfor
end