Index: /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyFromHostLocation.c
===================================================================
--- /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyFromHostLocation.c	(revision 33224)
+++ /branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyFromHostLocation.c	(revision 33225)
@@ -12,4 +12,5 @@
   char srcname[1024];
   char tgtname[1024];
+  char outdir[1024];
     
   md5_byte_t srcDigest[NDIGEST];
@@ -28,6 +29,6 @@
     if (!skylist->regions[i]->hostID) continue;
 
-    // skip catalogs which have not been copied back
-    if (skylist->regions[i]->hostFlags & DATA_ON_TGT) continue;
+    // skip catalogs which are not on remote location
+    if (!(skylist->regions[i]->hostFlags & DATA_ON_TGT)) continue;
 
     // skip catalogs which have an uncleared error
@@ -42,4 +43,14 @@
     int success = TRUE;
 
+    char *subdir = pathname (skylist->regions[i]->name);
+    sprintf (outdir, "%s/%s", host->pathname, subdir);
+    free (subdir);
+
+    int status = check_dir_access (outdir, DEBUG);
+    if (!status) {
+      fprintf (stderr, "failed to find / create target path\n");
+      exit (2);
+    }
+
     char extname[4][16] = {"cpm", "cpt", "cps", "cpn"};
     for (j = 0; success && (j < 4); j++) {
@@ -52,6 +63,6 @@
 
       // check permission to read file 
-      int status = stat (srcname, &filestat);
-      if (!status) {
+      status = stat (srcname, &filestat);
+      if (status) {
 	if (errno == ENOENT) continue;  // file does not exist (handle broken table with cpt + cpm but no cpn,cps?)
 	perror ("stat:");
