summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2011-08-30 20:52:04 (UTC)
committer Michael Krelin <hacker@klever.net>2011-08-30 20:52:04 (UTC)
commit55bdd80087710b94e747a622fad8bd0ee3e3dec3 (patch) (unidiff)
tree6d4b8ab76b18c7f6e3d6d2823470c8662cbdf8f5
parent77706495aa0cc1706cfe1535b40477e004312081 (diff)
downloadiii-55bdd80087710b94e747a622fad8bd0ee3e3dec3.zip
iii-55bdd80087710b94e747a622fad8bd0ee3e3dec3.tar.gz
iii-55bdd80087710b94e747a622fad8bd0ee3e3dec3.tar.bz2
updated list of supported suffixes
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyefiservice.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/eyefiservice.cc b/src/eyefiservice.cc
index d7f0f04..77526b9 100644
--- a/src/eyefiservice.cc
+++ b/src/eyefiservice.cc
@@ -1,17 +1,18 @@
1#include <cassert> 1#include <cassert>
2#include <iostream> 2#include <iostream>
3#include <fstream> 3#include <fstream>
4#include <stdexcept> 4#include <stdexcept>
5#include <iterator> 5#include <iterator>
6#include <algorithm>
6#include <syslog.h> 7#include <syslog.h>
7#include <sys/wait.h> 8#include <sys/wait.h>
8#include <autosprintf.h> 9#include <autosprintf.h>
9#include "eyekinfig.h" 10#include "eyekinfig.h"
10#include "eyetil.h" 11#include "eyetil.h"
11#include "soapeyefiService.h" 12#include "soapeyefiService.h"
12 13
13static binary_t session_nonce; 14static binary_t session_nonce;
14 15
15static bool detached_child() { 16static bool detached_child() {
16 pid_t p = fork(); 17 pid_t p = fork();
17 if(p<0) { 18 if(p<0) {
@@ -159,25 +160,28 @@ int eyefiService::UploadPhoto(
159 if(!digest.empty()) throw std::runtime_error("already have integrity digest"); 160 if(!digest.empty()) throw std::runtime_error("already have integrity digest");
160 digest = integrity_digest((*i).ptr,(*i).size,eyekinfig.get_upload_key()); 161 digest = integrity_digest((*i).ptr,(*i).size,eyekinfig.get_upload_key());
161#ifndef NDEBUG 162#ifndef NDEBUG
162 syslog(LOG_DEBUG," computed integrity digest=%s", digest.hex().c_str()); 163 syslog(LOG_DEBUG," computed integrity digest=%s", digest.hex().c_str());
163#endif 164#endif
164 165
165 tarchive_t a((*i).ptr,(*i).size); 166 tarchive_t a((*i).ptr,(*i).size);
166 while(a.read_next_header()) { 167 while(a.read_next_header()) {
167 std::string f = indir.get_file(a.entry_pathname()); 168 std::string f = indir.get_file(a.entry_pathname());
168 std::string::size_type fl = f.length(); 169 std::string::size_type fl = f.length();
169 if(fl<4) continue; 170 if(fl<4) continue;
170 const char *s = f.c_str()+fl-4; 171 const char *s = f.c_str()+fl-4;
171 if(!(strcasecmp(s,".JPG") && strcasecmp(s,".AVI"))) 172 static const char *suffixes[] = { ".JPG",".AVI",".MP4",".NEF",".RAW",".TIF" };
173 if(std::find_if(suffixes,suffixes+sizeof(suffixes)/sizeof(*suffixes),
174 std::not1(std::bind1st(std::ptr_fun(strcasecmp),s)))
175 != suffixes+sizeof(suffixes)/sizeof(*suffixes))
172 tf = f; 176 tf = f;
173 else if(!strcasecmp(s,".log")) 177 else if(!strcasecmp(s,".log"))
174 lf = f; 178 lf = f;
175 else continue; 179 else continue;
176 int fd=open(f.c_str(),O_CREAT|O_WRONLY,0666); 180 int fd=open(f.c_str(),O_CREAT|O_WRONLY,0666);
177 if(fd<0) 181 if(fd<0)
178 throw std::runtime_error(gnu::autosprintf("failed to create output file '%s'",f.c_str())); 182 throw std::runtime_error(gnu::autosprintf("failed to create output file '%s'",f.c_str()));
179 if(!a.read_data_into_fd(fd)) 183 if(!a.read_data_into_fd(fd))
180 throw std::runtime_error(gnu::autosprintf("failed to untar file into '%s'",f.c_str())); 184 throw std::runtime_error(gnu::autosprintf("failed to untar file into '%s'",f.c_str()));
181 close(fd); 185 close(fd);
182 } 186 }
183 } 187 }