HasContents attribute of Image objects after migration

If I'm correct, the HasContents attribute was introduced in Mendix version 2.5. We have migrated a 2.4 application with a lot of images and I'm not confident that all the images are available in the new application. The main reason for this is the following SQL statement being executed as part of the migration database changes: UPDATE [system$filedocument] SET [hascontents] = 1 WHERE NOT [name] IS NULL; Is it possible that there are images present in the UploadedFilesPath location that have a NULL value for the Name attribute? After all, in version 2.4 the Document/Name attribute wasn't required, right? The migration copies the old Document/Name attribute to the new FileDocument/Name attribute: UPDATE [system$filedocument] SET [name] = (SELECT [deleted_system$document].[name] FROM [deleted_system$document] WHERE [deleted_system$document].[id] = [system$filedocument].[id]) WHERE [id] IN (SELECT [deleted_system$document].[id] FROM [deleted_system$document]); If that is the case, the HasContents attribute doesn't properly reflect the fact that an actual file is present on the filesystem.
1 answers

I've managed to solve this issue myself. My assumption that the database migration script incorrectly sets HasContents to FALSE is true (we've tested this).

For those interested, I've written the following Python script to generate a usable SQL script to fix the issue:

import sys;
import os;

mycount = 0

def fixHasContents(basepath):
    if os.path.exists(basepath) and os.path.isdir(basepath):
        files = os.listdir(basepath)
        for f in files:
            listMxFiles(basepath, f)
        print "count: %i" % mycount
        print "Basepath '%s' does not exist or is not a directory" % basepath

def listMxFiles(basepath, file):
    global mycount
    filepath = basepath + os.sep + file
    if os.path.isfile(filepath):
        if file.isdigit():
            print "update system$filedocument set hascontents = 1 where id = %s;" % file
            mycount = mycount + 1
        if file.isdigit():
            files = os.listdir(filepath)
            for f in files:
                listMxFiles(filepath, f)

def printUsage():
    print "Usage: fixHasContents.py <data files basepath>"

if __name__ == "__main__":
    if len(sys.argv) > 1:
        basepath = os.path.realpath(sys.argv[1])
        print "Reading Mendix data files from basepath: %s" % basepath