summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2011-05-24 20:27:01 (UTC)
committer Michael Krelin <hacker@klever.net>2011-05-24 21:30:57 (UTC)
commit09b6e86aaad70bc7488604b2e291d098a7de0eac (patch) (unidiff)
tree1f79c3eea40a555cc5f354563d55ee773f75a6c7
parentf9b17f10f8f43da6998bbd1fb13d3a48c35ec653 (diff)
downloadiii-09b6e86aaad70bc7488604b2e291d098a7de0eac.zip
iii-09b6e86aaad70bc7488604b2e291d098a7de0eac.tar.gz
iii-09b6e86aaad70bc7488604b2e291d098a7de0eac.tar.bz2
don't whine there's no jpeg if there was avi
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyefiservice.cc26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/eyefiservice.cc b/src/eyefiservice.cc
index 4ca2777..d7f0f04 100644
--- a/src/eyefiservice.cc
+++ b/src/eyefiservice.cc
@@ -129,7 +129,7 @@ int eyefiService::UploadPhoto(
129 std::string td = eyekinfig.get_targetdir(); 129 std::string td = eyekinfig.get_targetdir();
130 tmpdir_t indir(td+"/.incoming.XXXXXX"); 130 tmpdir_t indir(td+"/.incoming.XXXXXX");
131 131
132 std::string jf,lf; 132 std::string tf,lf;
133 binary_t digest, idigest; 133 binary_t digest, idigest;
134 134
135 for(soap_multipart::iterator i=mime.begin(),ie=mime.end();i!=ie;++i) { 135 for(soap_multipart::iterator i=mime.begin(),ie=mime.end();i!=ie;++i) {
@@ -155,7 +155,7 @@ int eyefiService::UploadPhoto(
155 } 155 }
156#endif 156#endif
157 157
158 if(!jf.empty()) throw std::runtime_error("already seen tarball"); 158 if(!tf.empty()) throw std::runtime_error("already seen tarball");
159 if(!digest.empty()) throw std::runtime_error("already have integrity digest"); 159 if(!digest.empty()) throw std::runtime_error("already have integrity digest");
160 digest = integrity_digest((*i).ptr,(*i).size,eyekinfig.get_upload_key()); 160 digest = integrity_digest((*i).ptr,(*i).size,eyekinfig.get_upload_key());
161#ifndef NDEBUG 161#ifndef NDEBUG
@@ -168,8 +168,8 @@ int eyefiService::UploadPhoto(
168 std::string::size_type fl = f.length(); 168 std::string::size_type fl = f.length();
169 if(fl<4) continue; 169 if(fl<4) continue;
170 const char *s = f.c_str()+fl-4; 170 const char *s = f.c_str()+fl-4;
171 if(!strcasecmp(s,".JPG")) 171 if(!(strcasecmp(s,".JPG") && strcasecmp(s,".AVI")))
172 jf = f; 172 tf = f;
173 else if(!strcasecmp(s,".log")) 173 else if(!strcasecmp(s,".log"))
174 lf = f; 174 lf = f;
175 else continue; 175 else continue;
@@ -183,22 +183,22 @@ int eyefiService::UploadPhoto(
183 } 183 }
184 } 184 }
185 185
186 if(jf.empty()) throw std::runtime_error("haven't seen jpeg file"); 186 if(tf.empty()) throw std::runtime_error("haven't seen THE file");
187 if(digest!=idigest) throw std::runtime_error("integrity digest verification failed"); 187 if(digest!=idigest) throw std::runtime_error("integrity digest verification failed");
188 188
189 std::string::size_type ls = jf.rfind('/'); 189 std::string::size_type ls = tf.rfind('/');
190 // XXX: actually, lack of '/' signifies error here 190 // XXX: actually, lack of '/' signifies error here
191 std::string jbn = (ls==std::string::npos)?jf:jf.substr(ls+1); 191 std::string tbn = (ls==std::string::npos)?tf:tf.substr(ls+1);
192 ls = lf.rfind('/'); 192 ls = lf.rfind('/');
193 std::string lbn = (ls==std::string::npos)?lf:lf.substr(ls+1); 193 std::string lbn = (ls==std::string::npos)?lf:lf.substr(ls+1);
194 std::string tjf,tlf; 194 std::string ttf,tlf;
195 bool success = false; 195 bool success = false;
196 for(int i=0;i<32767;++i) { 196 for(int i=0;i<32767;++i) {
197 const char *fmt = i ? "%1$s/(%3$05d)%2$s" : "%1$s/%2$s"; 197 const char *fmt = i ? "%1$s/(%3$05d)%2$s" : "%1$s/%2$s";
198 tjf = (const char*)gnu::autosprintf(fmt,td.c_str(),jbn.c_str(),i); 198 ttf = (const char*)gnu::autosprintf(fmt,td.c_str(),tbn.c_str(),i);
199 if(!lf.empty()) tlf = (const char*)gnu::autosprintf(fmt,td.c_str(),lbn.c_str(),i); 199 if(!lf.empty()) tlf = (const char*)gnu::autosprintf(fmt,td.c_str(),lbn.c_str(),i);
200 if( (!link(jf.c_str(),tjf.c_str())) && (lf.empty()) || !link(lf.c_str(),tlf.c_str()) ) { 200 if( (!link(tf.c_str(),ttf.c_str())) && (lf.empty()) || !link(lf.c_str(),tlf.c_str()) ) {
201 unlink(jf.c_str()); 201 unlink(tf.c_str());
202 if(!lf.empty()) unlink(lf.c_str()); 202 if(!lf.empty()) unlink(lf.c_str());
203 success=true; 203 success=true;
204 break; 204 break;
@@ -207,9 +207,9 @@ int eyefiService::UploadPhoto(
207 std::string cmd = eyekinfig.get_on_upload_photo(); 207 std::string cmd = eyekinfig.get_on_upload_photo();
208 if(success && !cmd.empty()) { 208 if(success && !cmd.empty()) {
209 if(detached_child()) { 209 if(detached_child()) {
210 putenv( gnu::autosprintf("EYEFI_UPLOADED_ORIG=%s",jbn.c_str()) ); 210 putenv( gnu::autosprintf("EYEFI_UPLOADED_ORIG=%s",tbn.c_str()) );
211 putenv( gnu::autosprintf("EYEFI_MACADDRESS=%s",macaddress.c_str()) ); 211 putenv( gnu::autosprintf("EYEFI_MACADDRESS=%s",macaddress.c_str()) );
212 putenv( gnu::autosprintf("EYEFI_UPLOADED=%s",tjf.c_str()) ); 212 putenv( gnu::autosprintf("EYEFI_UPLOADED=%s",ttf.c_str()) );
213 if(!lf.empty()) putenv( gnu::autosprintf("EYEFI_LOG=%s",tlf.c_str()) ); 213 if(!lf.empty()) putenv( gnu::autosprintf("EYEFI_LOG=%s",tlf.c_str()) );
214 char *argv[] = { (char*)"/bin/sh", (char*)"-c", (char*)cmd.c_str(), 0 }; 214 char *argv[] = { (char*)"/bin/sh", (char*)"-c", (char*)cmd.c_str(), 0 };
215 execv("/bin/sh",argv); 215 execv("/bin/sh",argv);