@@ -224,26 +224,30 @@ func processFile(entry fs.DirEntry, fullPath string, path *string, dag *DagBuild
224224 builder .SetType (FileLeafType )
225225 fileChunks := chunkFile (fileData , ChunkSize )
226226
227- if len ( fileChunks ) == 1 {
228- builder .SetData (fileChunks [ 0 ] )
227+ if ChunkSize <= 0 {
228+ builder .SetData (fileData )
229229 } else {
230- for i , chunk := range fileChunks {
231- chunkEntryPath := filepath .Join (relPath , strconv .Itoa (i ))
232- chunkBuilder := CreateDagLeafBuilder (chunkEntryPath )
230+ if len (fileChunks ) == 1 {
231+ builder .SetData (fileChunks [0 ])
232+ } else {
233+ for i , chunk := range fileChunks {
234+ chunkEntryPath := filepath .Join (relPath , strconv .Itoa (i ))
235+ chunkBuilder := CreateDagLeafBuilder (chunkEntryPath )
233236
234- chunkBuilder .SetType (ChunkLeafType )
235- chunkBuilder .SetData (chunk )
237+ chunkBuilder .SetType (ChunkLeafType )
238+ chunkBuilder .SetData (chunk )
236239
237- // Chunks don't get custom metadata
238- chunkLeaf , err := chunkBuilder .BuildLeaf (nil )
239- if err != nil {
240- return nil , err
241- }
240+ // Chunks don't get custom metadata
241+ chunkLeaf , err := chunkBuilder .BuildLeaf (nil )
242+ if err != nil {
243+ return nil , err
244+ }
242245
243- label := dag .GetNextAvailableLabel ()
244- builder .AddLink (label , chunkLeaf .Hash )
245- chunkLeaf .SetLabel (label )
246- dag .AddLeaf (chunkLeaf , nil )
246+ label := dag .GetNextAvailableLabel ()
247+ builder .AddLink (label , chunkLeaf .Hash )
248+ chunkLeaf .SetLabel (label )
249+ dag .AddLeaf (chunkLeaf , nil )
250+ }
247251 }
248252 }
249253
@@ -973,3 +977,9 @@ func (d *Dag) ApplyTransmissionPacket(packet *TransmissionPacket) {
973977 }
974978 }
975979}
980+
981+ func (d * Dag ) RemoveAllContent () {
982+ for _ , leaf := range d .Leafs {
983+ leaf .Content = nil
984+ }
985+ }
0 commit comments