Skip to content

Commit

Permalink
actually tracking start/update times for contact/faves backup properl…
Browse files Browse the repository at this point in the history
…y and 'fix' the duplicate keys for faves problem in the process
  • Loading branch information
thisisaaronland committed Dec 8, 2011
1 parent 0130c2a commit a5cd733
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -88,8 +88,6 @@ TO DO:

* search, see also: [parallel-flickr-solr](https://github.com/straup/parallel-flickr-solr)

* duplicate key errors fetching faves

* better layout, tested in more than just Firefox

See also: [TODO.txt](https://github.com/straup/parallel-flickr/blob/master/TODO.txt)
Expand Down
17 changes: 11 additions & 6 deletions www/include/lib_flickr_backups.php
Expand Up @@ -210,15 +210,13 @@ function flickr_backups_get_faves(&$user){

$rsp = flickr_faves_import_for_nsid($flickr_user['nsid'], $more);

if (($rsp['ok']) && (! $backup['date_firstupdate'])){
$update['date_firstupdate'] = $update['date_lastupdate'];
}

#

if ($rsp['ok']){
$update['date_lastupdate'] = $start_time;
$update['details'] = "count: {$rsp['count_imported']}";

if (! $backup['date_firstupdate']){
$update['date_firstupdate'] = $update['date_lastupdate'];
}
}

else {
Expand All @@ -244,6 +242,9 @@ function flickr_backups_get_contacts(&$user){
);
}

$backup = $backups['contacts'];
$update = array();

$start_time = time();

$rsp = flickr_contacts_purge_contacts($user);
Expand All @@ -257,6 +258,10 @@ function flickr_backups_get_contacts(&$user){
if ($rsp['ok']){
$update['date_lastupdate'] = $start_time;
$update['details'] = "count: {$rsp['count_imported']}";

if (! $backup['date_firstupdate']){
$update['date_firstupdate'] = $update['date_lastupdate'];
}
}

else {
Expand Down
17 changes: 14 additions & 3 deletions www/include/lib_flickr_photos_import.php
Expand Up @@ -162,12 +162,18 @@ function flickr_photos_import_photo_files(&$photo, $more=array()){

$small = "{$root}_{$photo['secret']}_z.jpg";

$ext = ($photo["originalsecret"]) ? $photo["originalformat"] : "jpg";

if ($photo['originalsecret']){
$orig = "{$root}_{$photo['originalsecret']}_o.{$photo['originalformat']}";

# This is probably really only necessary for
# Cal's account (20111208/straup)

$orig = ($ext) ? "{$root}_{$photo['originalsecret']}_o.{$ext}" : null;
}

else {
$orig = "{$root}_{$photo['secret']}_b.jpg";
$orig = "{$root}_{$photo['secret']}_b.{$ext}";
}

if ($photo['media'] == 1){
Expand Down Expand Up @@ -207,7 +213,12 @@ function flickr_photos_import_photo_files(&$photo, $more=array()){
}

if (($more['force']) || (! file_exists($local_orig))){
$req[] = array($orig, $local_orig);

# see above

if ($orig){
$req[] = array($orig, $local_orig);
}
}

# for now, just always fetch meta files because who knows
Expand Down

0 comments on commit a5cd733

Please sign in to comment.