00001 #include "up_private.h" 00002 00003 #include "ac_app_context.h" 00004 00005 #include "common/assertions.h" 00006 00007 // -------------------------------------------------- 00008 // directory scanning 00009 // -------------------------------------------------- 00010 00011 // It is possible that the Uploader takes a snapshot but then fails to 00012 // upload it before it is killed. Hence there might be snapshots 00013 // waiting for a later upload. We scan the uploads directory to find 00014 // such files, and upload and delete one at a time as our first 00015 // priority until there are none left. The up_Uploader_upload_now 00016 // function will cause the next snapshot time to be set to current 00017 // time, but that is it, the snapshot will not actually be taken 00018 // before any old files have been handled. 00019 00020 // Sets the full pathname to *pathname. 00021 // This sets *pathname to NULL if there are no more files. 00022 // The caller must free any set pathname. 00023 gboolean getNextOldLogFile(gchar** pathname, 00024 GError** error) 00025 { 00026 assert(pathname && !*pathname); 00027 00028 GDir* dir = NULL; 00029 00030 TRAP_OOM_FAIL({ 00031 dir = g_dir_open(LOG_UPLOADS_DIR, 0, error); 00032 if (!dir) 00033 return FALSE; 00034 const gchar* filename = g_dir_read_name(dir); 00035 if (filename) { 00036 *pathname = g_strdup_printf("%s" DIR_SEP "%s", LOG_UPLOADS_DIR, filename); 00037 } 00038 }); 00039 00040 g_dir_close(dir); 00041 return TRUE; 00042 00043 #if HAVE_TRAP_OOM 00044 fail: 00045 if (dir) g_dir_close(dir); 00046 if (error) *error = gx_error_no_memory; 00047 return FALSE; 00048 #endif 00049 } 00050 00051 /** 00052 00053 Copyright 2009 Helsinki Institute for Information Technology (HIIT) 00054 and the authors. All rights reserved. 00055 00056 Authors: Tero Hasu <tero.hasu@hut.fi> 00057 00058 Permission is hereby granted, free of charge, to any person 00059 obtaining a copy of this software and associated documentation files 00060 (the "Software"), to deal in the Software without restriction, 00061 including without limitation the rights to use, copy, modify, merge, 00062 publish, distribute, sublicense, and/or sell copies of the Software, 00063 and to permit persons to whom the Software is furnished to do so, 00064 subject to the following conditions: 00065 00066 The above copyright notice and this permission notice shall be 00067 included in all copies or substantial portions of the Software. 00068 00069 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00070 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00071 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00072 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00073 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00074 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00075 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00076 SOFTWARE. 00077 00078 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:56 2011 by Doxygen 1.6.1