class EL_RESOURCE_UPDATE_MANAGER
Manager to update a directory of file items with common extension by HTTP download. Updates are installed in a user directory.
note
description: "[
Manager to update a directory of file items with common extension by HTTP download.
Updates are installed in a user directory.
]"
author: "Finnian Reilly"
copyright: "Copyright (c) 2001-2022 Finnian Reilly"
contact: "finnian at eiffel hyphen loop dot com"
license: "MIT license (See: en.wikipedia.org/wiki/MIT_License)"
date: "2022-11-15 19:56:06 GMT (Tuesday 15th November 2022)"
revision: "6"
deferred class
EL_RESOURCE_UPDATE_MANAGER
inherit
EL_RESOURCE_INSTALL_MANAGER
rename
make as make_default
redefine
target_dir, existing_modification_time, download
end
EL_MODULE_FILE; EL_MODULE_NAMING
feature {NONE} -- Initialization
make (a_server_manifest_date: INTEGER)
do
make_default
server_manifest_date := a_server_manifest_date
end
feature -- Basic operations
extend (download_list: LIST [EL_DOWNLOADEABLE_RESOURCE])
do
download_manifest
if not has_error then
download_list.extend (Current)
end
end
download
do
Precursor
File_system.make_directory (date_file_path.parent)
File.write_text (date_file_path, server_manifest_date.out)
end
feature -- Status query
has_update: BOOLEAN
-- The server has a newer manifest
do
Result := server_manifest_date > local_manifest_date
end
feature {NONE} -- Implementation
date_file_path: FILE_PATH
do
Result := updated_dir + (Naming.class_as_kebab_lower (Current, 0, 1) + ".date")
end
existing_modification_time (item: EL_FILE_MANIFEST_ITEM): INTEGER
do
Result := Precursor (item)
if Result = 0 then
Result := modification_time (installed_dir, item)
end
end
local_manifest_date: INTEGER
do
if date_file_path.exists then
Result := File.plain_text (date_file_path).to_integer
end
end
target_dir: DIR_PATH
-- target directory to download items
do
Result := updated_dir
end
feature {NONE} -- Internal attributes
server_manifest_date: INTEGER
end