def get_objects_on_disk()

in pantri/scripts/lib/pantri.py [0:0]


    def get_objects_on_disk(self):
        """
        get_objects_on_disk(self)

        Walk though local storage and build one giant dictionary of objects on disk
        """

        objects_on_disk = {}
        download_path = self.options["dest_sync"]
        if "shelf" in self.options:
            download_path = os.path.join(download_path, self.options["shelf"])

        for (root, _dirs, files) in os.walk(download_path):
            for f in files:
                obj = os.path.join(root, f)
                object_name = utils.unix_path(
                    os.path.relpath(obj, self.options["dest_sync"])
                )
                # Return sha1 hash if checksum is enabled
                if self.options["checksum"]:
                    objects_on_disk.update(
                        {object_name: {"sha1_hash": utils.get_sha1(obj)}}
                    )
                else:
                    objects_on_disk.update(
                        {
                            object_name: {
                                "modified_time": utils.get_modified_time(obj),
                                "file_size": utils.get_file_size(obj),
                            }
                        }
                    )

        return objects_on_disk