Package org.syncany.chunk.Chunker

Examples of org.syncany.chunk.Chunker.ChunkEnumeration


      // Decide whether to index the contents
      boolean dedupContents = listener.onFileStart(file, i);

      if (dedupContents) {
        // Create chunks from file
        ChunkEnumeration chunksEnum = chunker.createChunks(file);

        while (chunksEnum.hasMoreElements()) {
          chunk = chunksEnum.nextElement();

          // old chunk
          if (!listener.onChunk(chunk)) {
            listener.onFileAddChunk(file, chunk);
            continue;
          }

          // new chunk
          else {         
            // - Check if multichunk full
            if (multiChunk != null && multiChunk.isFull()) {
              multiChunk.close();
              listener.onMultiChunkClose(multiChunk);

              multiChunk = null;
            }

            // - Open new multichunk if non-existent
            if (multiChunk == null) {
              MultiChunkId newMultiChunkId = listener.createNewMultiChunkId(chunk);
              File multiChunkFile = listener.getMultiChunkFile(newMultiChunkId);
             
              multiChunk = multiChunker.createMultiChunk(newMultiChunkId,
                transformer.createOutputStream(new FileOutputStream(multiChunkFile)));

              listener.onMultiChunkOpen(multiChunk);
            }

            // - Add chunk data
            multiChunk.write(chunk);           
            listener.onMultiChunkWrite(multiChunk, chunk);           
          }

          listener.onFileAddChunk(file, chunk);                   
        }

        // Closing file is necessary!
        chunksEnum.close();
      }

      if (chunk != null) {     
        listener.onFileEnd(file, chunk.getFileChecksum());
      }
View Full Code Here

TOP

Related Classes of org.syncany.chunk.Chunker.ChunkEnumeration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.