<!--
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author: yurize@apache.org (Yuri Zelikov)
 -->

<project name="migrate-attachments" default="migrate">
  <description>Migrates attachments to a newer version.</description>

  <property file="server.config" />
  <property name="attachments_tmp" value="attachments_tmp" />

  <target name="migrate" description="Migrates attachments to a newer version by moving all the
    files into the root folder.">
    <delete dir="${attachments_tmp}" failonerror="false" />
    <mkdir dir="${attachments_tmp}" />
    <copy todir="${attachments_tmp}" flatten="true" includeemptydirs="false">
      <fileset dir="${attachment_store_directory}">
        <include name="**/**/*" />
      </fileset>
    </copy>
    <delete dir="${attachment_store_directory}" failonerror="true" />
    <mkdir dir="${attachment_store_directory}" />
    <copy todir="${attachment_store_directory}">
      <fileset dir="${attachments_tmp}">
        <include name="**/**/*" />
      </fileset>
    </copy>
    <delete dir="${attachments_tmp}" failonerror="true" />
  </target>
</project>