timeshift icon indicating copy to clipboard operation
timeshift copied to clipboard

[CLI] --tags O option return an error

Open Freeman73 opened this issue 3 years ago • 4 comments

This is a free application that is provided "as-is" without support or warranty. It is updated once a year due to a lack of time, developers, and funds. You can support this project by making a donation with PayPal

Describe the bug When creating a snapshot from a CLI, if --tags is used with value O, error is returned. Other tags work, O is the default behaviour, so not using --tags in the first place circumvents the bug. According to man page, using value "O" should be possible: --tags {O,B,H,D,W,M} Add tags to snapshot (default: O)

To Reproduce Steps to reproduce the behavior: sudo timeshift --create --comments "main" --tags O --verbose

Expected behavior A restore point is created with an "On demand" tag.

Screenshots It is a CLI problem, the verbose error output is: E: Unknown value specified for option --tags (O). E: Expected values: O, B, H, D, W, M

System:

  • Linux Distribution Name and Version: LMDE4 (Linux Mind Debian Edition 4), Ubuntu 20.04 LTS
  • Desktop headless, cinnamon
  • Application Version v20.11.1

Freeman73 avatar Dec 10 '21 00:12 Freeman73

Issue seems to be in the method validate_cmd_tags() and set_tags(Snapshot snapshot), located in "timeshift/src/Core/Main.vala".

The code should probably be:


	private void set_tags(Snapshot snapshot){

		// add tags passed on commandline for both --check and --create
		
		foreach(string tag in cmd_tags.split(",")){
			switch(tag.strip().up()){
			case "B":
				snapshot.add_tag("boot");
				break;
			case "H":
				snapshot.add_tag("hourly");
				break;
			case "D":
				snapshot.add_tag("daily");
				break;
			case "W":
				snapshot.add_tag("weekly");
				break;
			case "M":
				snapshot.add_tag("monthly");
				break;
			}
			case "O":
				snapshot.add_tag("ondemand");
				break;
			}
		}

		// add tag as ondemand if no other tag is specified
		
		if (snapshot.tags.size == 0){
			snapshot.add_tag("ondemand");
		}
	}

	public void validate_cmd_tags(){
		foreach(string tag in cmd_tags.split(",")){
			switch(tag.strip().up()){
			case "O":
			case "B":
			case "H":
			case "D":
			case "W":
			case "M":
				break;
			default:
				log_error(_("Unknown value specified for option --tags") + " (%s).".printf(tag));
				log_error(_("Expected values: O, B, H, D, W, M"));
				exit_app(1);
				break;
			}
		}
	}

But I don't understand the code enough to confidently submit it as a pull request.

Freeman73 avatar Dec 10 '21 01:12 Freeman73

I got the problem too. Can't set ondemand tag O because I'll get the same error:

Unknown value specified for option --tags (O).

Unrepentant-Atheist avatar Mar 05 '22 00:03 Unrepentant-Atheist

Same issue. sudo timeshift --create --comments "First:" --tags O doesnt work

doxxedd avatar Aug 26 '22 02:08 doxxedd

Wat do? Problem still be.

Unrepentant-Atheist avatar Oct 10 '22 21:10 Unrepentant-Atheist