Revision 1832
| trunk/nntpgrab_core/queue_rawfile.c (revision 1832) | ||
|---|---|---|
| 118 | 118 | 
                              char *tmp = g_strdup_printf("%s%s", filename, ".new");
                 | 
              
| 119 | 119 | 
                   | 
              
| 120 | 120 | 
                              if (g_rename(tmp, filename) == -1) {
                 | 
              
| 121 | 
                  #ifdef WIN32  | 
              |
| 122 | 
                  /* The rename can fail on Win32 if the dest file already exists or some virus scanner is claiming the file */  | 
              |
| 123 | 
                  /* Try removing the dest file first and try to rename again afterwards */  | 
              |
| 124 | 
                                  if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
                 | 
              |
| 125 | 
                                      if (errmsg) {
                 | 
              |
| 126 | 
                                          *errmsg = g_strdup_printf(_("Unable to rename temporary download queue file '%s' to '%s': %s"), tmp, filename, strerror(errno));
                 | 
              |
| 127 | 
                                      } else {
                 | 
              |
| 128 | 
                                          g_warning(_("Unable to rename temporary download queue file '%s' to '%s': %s"), tmp, filename, strerror(errno));
                 | 
              |
| 129 | 
                  }  | 
              |
| 130 | 
                   | 
              |
| 131 | 
                  ret = FALSE;  | 
              |
| 132 | 
                                  } else {
                 | 
              |
| 133 | 
                  /* Dest file exists, try to remove the dest file */  | 
              |
| 134 | 
                                      if (g_unlink(filename) == -1) {
                 | 
              |
| 135 | 
                                          if (errmsg) {
                 | 
              |
| 136 | 
                                              *errmsg = g_strdup_printf(_("Unable to remove existing download queue '%s': %s"), filename, strerror(errno));
                 | 
              |
| 137 | 
                                          } else {
                 | 
              |
| 138 | 
                                              g_warning(_("Unable to remove existing download queue '%s': %s"), filename, strerror(errno));
                 | 
              |
| 139 | 
                  }  | 
              |
| 140 | 
                   | 
              |
| 141 | 
                  ret = FALSE;  | 
              |
| 142 | 
                                      } else {
                 | 
              |
| 143 | 
                  /* Remove failed, try to rename again */  | 
              |
| 144 | 
                                          if (g_rename(tmp, filename) == -1) {
                 | 
              |
| 145 | 
                                              if (errmsg) {
                 | 
              |
| 146 | 
                                                  *errmsg = g_strdup_printf(_("Unable to rename temporary download queue file '%s' to '%s': %s"), tmp, filename, strerror(errno));
                 | 
              |
| 147 | 
                                              } else {
                 | 
              |
| 148 | 
                                                  g_warning(_("Unable to rename temporary download queue file '%s' to '%s': %s"), tmp, filename, strerror(errno));
                 | 
              |
| 149 | 
                  }  | 
              |
| 150 | 
                   | 
              |
| 151 | 
                  ret = FALSE;  | 
              |
| 152 | 
                  }  | 
              |
| 153 | 
                  }  | 
              |
| 154 | 
                  }  | 
              |
| 155 | 
                  #else  | 
              |
| 121 | 156 | 
                                  if (errmsg) {
                 | 
              
| 122 | 157 | 
                                      *errmsg = g_strdup_printf(_("Unable to rename temporary download queue file '%s' to '%s': %s"), tmp, filename, strerror(errno));
                 | 
              
| 123 | 158 | 
                                  } else {
                 | 
              
| ... | ... | |
| 125 | 160 | 
                  }  | 
              
| 126 | 161 | 
                   | 
              
| 127 | 162 | 
                  ret = FALSE;  | 
              
| 163 | 
                  #endif  | 
              |
| 128 | 164 | 
                  }  | 
              
| 129 | 165 | 
                  g_free(tmp);  | 
              
| 130 | 166 | 
                  g_free(filename);  | 
              
Also available in: Unified diff
NNTPGrab

