mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

boli
19.17.2007 2b48ed4d7ff1accde1eb21a1e1afe5ab553fd7d0
Fix issue where backups of an empty backend would fail. Added a placeholder file in the zip stream if the backend is empty. On restore, this file will not be restored.

Fix for issue 969
1 files modified
37 ■■■■■ changed files
opends/src/server/org/opends/server/backends/jeb/BackupManager.java 37 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/backends/jeb/BackupManager.java
@@ -108,6 +108,12 @@
  public static final String ZIPENTRY_UNCHANGED_LOGFILES = "unchanged.txt";
  /**
   * The name of a dummy entry in the backup archive file that will act
   * as a placeholder in case a backup is done on an empty backend.
   */
  public static final String ZIPENTRY_EMPTY_PLACEHOLDER = "empty.placeholder";
  /**
   * The fully-qualified name of this class for debugging purposes.
   */
  private static final String CLASS_NAME =
@@ -436,7 +442,27 @@
      message = getMessage(msgID, backendDir.getAbsolutePath(),
                           stackTraceToSingleLineString(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, msgID, e);
          message, msgID, e);
    }
    // Check to see if backend is empty. If so, insert placeholder entry into
    // archive
    if(logFiles.length <= 0)
    {
      try
      {
        ZipEntry emptyPlaceholder = new ZipEntry(ZIPENTRY_EMPTY_PLACEHOLDER);
        zipStream.putNextEntry(emptyPlaceholder);
      }
      catch (IOException e)
      {
        assert debugException(CLASS_NAME, "createBackup", e);
        msgID   = MSGID_JEB_BACKUP_CANNOT_WRITE_ARCHIVE_FILE;
        message = getMessage(msgID, ZIPENTRY_EMPTY_PLACEHOLDER,
            stackTraceToSingleLineString(e));
        throw new DirectoryException(
            DirectoryServer.getServerErrorResultCode(), message, msgID, e);
      }
    }
    // Sort the log files from oldest to youngest since this is the order
@@ -988,6 +1014,15 @@
    {
      String name = zipEntry.getName();
      if (name.equals(ZIPENTRY_EMPTY_PLACEHOLDER))
      {
        // This entry is treated specially to indicate a backup of an empty
        // backend was attempted.
        zipEntry = zipStream.getNextEntry();
        continue;
      }
      if (name.equals(ZIPENTRY_UNCHANGED_LOGFILES))
      {
        // This entry is treated specially. It is never restored,