lib/roku_builder/loader.rb in roku_builder-3.8.5 vs lib/roku_builder/loader.rb in roku_builder-3.9.0
- old
+ new
@@ -19,19 +19,23 @@
result = FAILED_SIDELOAD
outfile = nil
build_version = nil
if infile
build_version = ManifestManager.build_version(root_dir: infile)
+ return [MISSING_MANIFEST, nil] if outfile == MISSING_MANIFEST
outfile = infile
else
# Update manifest
if update_manifest
build_version = ManifestManager.update_build(root_dir: @root_dir)
+ return [MISSING_MANIFEST, nil] if outfile == MISSING_MANIFEST
else
build_version = ManifestManager.build_version(root_dir: @root_dir)
+ return [MISSING_MANIFEST, nil] if outfile == MISSING_MANIFEST
end
outfile = build(build_version: build_version, content: content)
+ return [MISSING_MANIFEST, nil] if outfile == MISSING_MANIFEST
end
path = "/plugin_install"
# Connect to roku and upload file
conn = multipart_connection
payload = {
@@ -53,10 +57,11 @@
# @param outfile [String] Path for the output file. If nil will create a file in /tmp. Default: nil
# @param content [Hash] Hash containing arrays for folder, files, and excludes. Default: nil
# @return [String] Path of the build
def build(build_version: nil, outfile: nil, content: nil)
build_version = ManifestManager.build_version(root_dir: @root_dir) unless build_version
+ return MISSING_MANIFEST if build_version == MISSING_MANIFEST
content ||= {}
unless content and content[:folders]
content[:folders] = Dir.entries(@root_dir).select {|entry| File.directory? File.join(@root_dir, entry) and !(entry =='.' || entry == '..') }
end
unless content and content[:files]
@@ -67,14 +72,18 @@
File.delete(outfile) if File.exist?(outfile)
io = Zip::File.open(outfile, Zip::File::CREATE)
# Add folders to zip
content[:folders].each do |folder|
base_folder = File.join(@root_dir, folder)
- entries = Dir.entries(base_folder)
- entries.delete(".")
- entries.delete("..")
- writeEntries(@root_dir, entries, folder, content[:excludes], io)
+ if File.exist?(base_folder)
+ entries = Dir.entries(base_folder)
+ entries.delete(".")
+ entries.delete("..")
+ writeEntries(@root_dir, entries, folder, content[:excludes], io)
+ else
+ @logger.warn "Missing Folder: #{base_folder}"
+ end
end
# Add file to zip
writeEntries(@root_dir, content[:files], "", content[:excludes], io)
io.close()
outfile
@@ -112,10 +121,14 @@
io.mkdir(zipFilePath)
subdir =Dir.entries(diskFilePath); subdir.delete("."); subdir.delete("..")
writeEntries(root_dir, subdir, zipFilePath, excludes, io)
else
unless excludes.include?(zipFilePath)
- io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, "rb").read()) }
+ if File.exist?(diskFilePath)
+ io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, "rb").read()) }
+ else
+ @logger.warn "Missing File: #{diskFilePath}"
+ end
end
end
}
end
end