Advertisement
MrRiptidePastes

update test

Jun 14th, 2021 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local FILENAME = '/test.lua'
  2. local internet = require("internet")
  3.  
  4. local cacheBreak = tostring(math.random(0, 99999))
  5.  
  6. local response = internet.request('https://raw.githubusercontent.com/MrRiptide/OpenComputers/master/test.lua?breaker=' .. cacheBreak)
  7. local code = ""
  8.  
  9. for chunk in response do
  10. code = code .. chunk
  11. end
  12.  
  13. if not(filesystem.exists(FILENAME))
  14. then
  15. local newHarvest = io.open(FILENAME, 'w')
  16. newHarvest:close()
  17. end
  18.  
  19. local readFile = io.open(FILENAME, 'r')
  20. local oldCode = readFile:read("*a")
  21. readFile:close()
  22.  
  23. local file = io.open(FILENAME, 'w')
  24.  
  25. if oldCode == code
  26. then
  27. file:write(oldCode)
  28. print('NO CHANGES MADE - Same Code')
  29. else
  30. file:write(code)
  31. print('WRITING UPDATE')
  32. byteDiff = string.len(code) - string.len(oldCode)
  33.  
  34. if byteDiff >= 0
  35. then
  36. print(tostring(math.abs(byteDiff)) .. ' bytes added')
  37. else
  38. print(tostring(math.abs(byteDiff)) .. ' bytes removed')
  39. end
  40. end
  41.  
  42. file:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement