Finding Large CMS Files

By means of the Tcl procedure below, findLargeBlobs, you can find large CMS files in order to delete their archived versions, for example. You can integrate the procedure in the following way:

  1. Store the Tcl code below in a file (e.g. findLargeBlobs.tcl) in the FionaDir/instance/InstanceDir/script/cm/clientCmds directory, where FionaDir is your Fiona installation directory and InstanceDir is your instance directory. When the CM is started the next time, this file will be loaded automatically so that the procedure is available. If you do not wish to restart the CM, load the script manually using the source command as described below.

  2. In the CMS instance to examine, open the Tcl client by executing ./client in the bin directiory and then connecting to the CM using connect:

    ./client
    connect hostname port username password

    Example: connect localhost 3001 root demo

  3. If the procedure has not been loaded at startup, because it was not found in the directory specified above, please load it manually:

    source FionaDir/instance/InstanceDir/script/cm/clientCmds/findLargeBlobs.tcl

    Again, replace FionaDir and InstanceDir with your Fiona installation directory and your instance name, respectively.

  4. You can now call the procedure. Specify as the first argument the path or the ID of the folder where the search is to begin. As the second argument specify the maximum number of bytes to be ignored. Example:

    findLargeBlobs /myContentFolder 32768

    This call will find CMS files larger than 32 KB if they are located in the /myContentFolder CMS folder or the hierarchy below it.

  5. The result can be found in the file FionaDir/instance/InstanceDir/tmp/largeBlobs.log, where the placeholders again need to be replaced with the actual directory names.

    The output includes the sizes of the draft and the released versions as well as the number of versions the respective file has. The output is in the following format:

    /myContentFolder/SubFolder/FileName
      editedBlobLength: 45239
      releasedBlobLength: 44387
      versions: 2

Code of the findLargeBlobs procedure

proc findLargeBlobs {pathOrId maxSize} {
  if {[catch {findObjectId $pathOrId} msg]} {
      error "$msg"
  } else {
    set objId $msg

    set fh [open [app get tmpDir]/largeBlobs.log w+]

    foreach o [objWherePath $objId] {                         
      set edited [obj withId $o get isEdited] 
      set released [obj withId $o get isReleased]
      set versions [llength [obj withId $o get contentIds]]
      if {$edited} {
        if {[obj withId $o editedContent get blobLength] > $maxSize} {
           set editedBlobLength [obj withId $o editedContent get blobLength]
        }
      }

      if {$released} {
        if {[obj withId $o releasedContent get blobLength] > $maxSize} {
           set releasedBlobLength [obj withId $o releasedContent get blobLength]
        }
      }

      if {[info exists editedBlobLength] || [info exists releasedBlobLength]} {
        puts $fh [obj withId $o get path]
        if {[info exists editedBlobLength]} {
          puts $fh "  editedBlobLength: $editedBlobLength"
        }
        if {[info exists releasedBlobLength]} {
          puts $fh "  releasedBlobLength: $releasedBlobLength"
        }
        puts $fh "  versions: $versions"
      }
      flush $fh
      catch {unset editedBlobLength}
      catch {unset releasedBlobLength}
    }

    close $fh
  }
}