コード例 #1
0
ファイル: FTPDB.py プロジェクト: steppicrew/VanDusenServer
 def insert_file(self, p_file, size, date, s_md5=None):
     """inserts file into ftp table"""
     t_file = self.parse_file_param(p_file)
     if s_md5 == None:
         s_md5 = calc_md5(self.local_file_name(t_file))
     self.remove_file(t_file)
     if self._db_update(
         "INSERT INTO ftpfiles ("
         "path, name, size, date, md5, current, lastseen"
         ") "
         "VALUES (?, ?, ?, ?, ?, 2, DATETIME('NOW'))",
         t_file + (size, date, s_md5),
     ).rowcount:
         return s_md5
     return None
コード例 #2
0
ファイル: DupMerge.py プロジェクト: steppicrew/VanDusenServer
 def insert_file(self,  p_file,  size= None,  date= None,  u_md5= None):
     """inserts a single file"""
     t_file = self.parse_file_param(p_file)
     u_local_file = self.local_file_name(t_file)
     self.remove_file(t_file)
     if size == None:
         size = os.path.getsize(u_local_file)
     if date == None:
         date = int(os.path.getmtime(u_local_file))
     if u_md5 == None:
         u_md5 = calc_md5(u_local_file)
     if self._db_update(
         "INSERT INTO files (path, name, size, date, md5) "
         "VALUES (?, ?, ?, ?, ?)",
         t_file + (size,  date,  u_md5)
     ).rowcount:
         self._logger.info("File '" + u_local_file + "' added.")
         return (size,  date,  u_md5)
     return None